How to use changeCodeName method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...2080 loggerSelf.logCall()2081 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2082 loggerSelf.logReturn(retval, tip=origMethod.func_name)2083 return retval2084 loggerSelf.changeCodeName(origMethodWRAP, origMethod.func_code.co_name + "WRAP")2085 return origMethodWRAP2086 def messageLogger(loggerSelf, origMethod):2087 def origMethodWRAP(*args, **kwargs):2088 loggerSelf.logMessage(" ".join([str(a) for a in args]))2089 return True2090 loggerSelf.changeCodeName(origMethodWRAP, origMethod.func_code.co_name + "WRAP")2091 return origMethodWRAP2092 def dragLogger(loggerSelf, origMethod):2093 def dragWRAP(*args, **kwargs):2094 loggerSelf.logCall()2095 x1, y1 = args[0]2096 x2, y2 = args[1]2097 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2098 try:2099 screenshotFilename = loggerSelf._device.screenshot().filename()2100 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2101 iC = loggerSelf._device.intCoords2102 eyenfinger.drawLines(screenshotFilename, highlightFilename, [], [iC((x1, y1)), iC((x2, y2))])2103 loggerSelf.logReturn(retval, img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name)2104 except:2105 loggerSelf.logReturn(str(retval) + " (no screenshot available)", tip=origMethod.func_name)2106 return retval2107 return dragWRAP2108 def refreshScreenshotLogger(loggerSelf, origMethod):2109 def refreshScreenshotWRAP(*args, **kwargs):2110 loggerSelf._highlightCounter = 02111 logCallReturnValue = loggerSelf.logCall()2112 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2113 retval._logCallReturnValue = logCallReturnValue2114 loggerSelf.logReturn(retval, img=retval, tip=origMethod.func_name)2115 retval.findItemsByBitmap = loggerSelf.findItemsByBitmapLogger(retval.findItemsByBitmap, retval)2116 retval.findItemsByOcr = loggerSelf.findItemsByOcrLogger(retval.findItemsByOcr, retval)2117 return retval2118 return refreshScreenshotWRAP2119 def tapLogger(loggerSelf, origMethod):2120 def tapWRAP(*args, **kwargs):2121 loggerSelf.logCall()2122 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2123 try:2124 screenshotFilename = loggerSelf._device.screenshot().filename()2125 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2126 eyenfinger.drawClickedPoint(screenshotFilename, highlightFilename, loggerSelf._device.intCoords(args[0]))2127 loggerSelf.logReturn(retval, img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name, imgTip=loggerSelf._device.screenshot()._logCallReturnValue)2128 except:2129 loggerSelf.logReturn(str(retval) + " (no screenshot available)", tip=origMethod.func_name)2130 return retval2131 return tapWRAP2132 def findItemsByBitmapLogger(loggerSelf, origMethod, screenshotObj):2133 def findItemsByBitmapWRAP(*args, **kwargs):2134 bitmap = args[0]2135 absPathBitmap = screenshotObj._paths.abspath(bitmap)2136 if loggerSelf._copyBitmapsToScreenshotDir:2137 screenshotDirBitmap = os.path.join(2138 os.path.dirname(screenshotObj.filename()),2139 "bitmaps",2140 bitmap.lstrip(os.sep))2141 if not os.access(screenshotDirBitmap, os.R_OK):2142 # bitmap is not yet copied under screenshotDir2143 destDir = os.path.dirname(screenshotDirBitmap)2144 if not os.access(destDir, os.W_OK):2145 try:2146 os.makedirs(destDir)2147 except IOError:2148 pass # cannot make dir / dir not writable2149 try:2150 shutil.copy(absPathBitmap, destDir)2151 absPathBitmap = screenshotDirBitmap2152 except IOError:2153 pass # cannot copy bitmap2154 else:2155 absPathBitmap = screenshotDirBitmap2156 loggerSelf.logCall(img=absPathBitmap)2157 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2158 if len(retval) == 0:2159 loggerSelf.logReturn("not found in", img=screenshotObj, tip=origMethod.func_name)2160 else:2161 foundItems = retval2162 screenshotFilename = screenshotObj.filename()2163 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2164 eyenfinger.drawIcon(screenshotFilename, highlightFilename, bitmap, [i.bbox() for i in foundItems])2165 loggerSelf.logReturn([str(quiItem) for quiItem in retval], img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name, imgTip=screenshotObj._logCallReturnValue)2166 return retval2167 return findItemsByBitmapWRAP2168 def findItemsByOcrLogger(loggerSelf, origMethod, screenshotObj):2169 def findItemsByOcrWRAP(*args, **kwargs):2170 loggerSelf.logCall()2171 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2172 if len(retval) == 0:2173 loggerSelf.logReturn("not found in words " + str(screenshotObj.dumpOcrWords()),2174 img=screenshotObj, tip=origMethod.func_name)2175 else:2176 foundItem = retval[0]2177 screenshotFilename = screenshotObj.filename()2178 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2179 eyenfinger.drawIcon(screenshotFilename, highlightFilename, args[0], foundItem.bbox())2180 for appearance, foundItem in enumerate(retval[1:42]):2181 eyenfinger.drawIcon(highlightFilename, highlightFilename, str(appearance+1) + ": " + args[0], foundItem.bbox())2182 loggerSelf.logReturn([str(retval[0])], img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name, imgTip=screenshotObj._logCallReturnValue)2183 return retval2184 return findItemsByOcrWRAP2185 def relFilePath(self, fileOrDirName, fileLikeObj):2186 if hasattr(fileLikeObj, "name"):2187 referenceDir = os.path.dirname(fileLikeObj.name)2188 else:2189 return fileOrDirName # keep it absolute if there's no reference2190 return os.path.relpath(fileOrDirName, referenceDir)2191 def imgToHtml(self, img, width="", imgTip="", imgClass=""):2192 if imgClass: imgClassAttr = 'class="%s" ' % (imgClass,)2193 else: imgClassAttr = ""2194 if isinstance(img, Screenshot):2195 imgHtmlName = self.relFilePath(img.filename(), self._outFileObj)2196 imgHtml = '<tr><td></td><td><img %stitle="%s" src="%s" width="%s" alt="%s" /></td></tr>' % (2197 imgClassAttr,2198 "%s refreshScreenshot() at %s:%s" % img._logCallReturnValue,2199 imgHtmlName,2200 self._screenshotWidth,2201 imgHtmlName)2202 elif img:2203 if width: width = 'width="%s"' % (width,)2204 if type(imgTip) == tuple and len(imgTip) == 3:2205 imgTip = 'title="%s refreshScreenshot() at %s:%s"' % imgTip2206 else:2207 imgTip = 'title="%s"' % (imgTip,)2208 imgHtmlName = self.relFilePath(img, self._outFileObj)2209 imgHtml = '<tr><td></td><td><img %s%s src="%s" %s alt="%s" /></td></tr>' % (2210 imgClassAttr, imgTip, imgHtmlName, width, imgHtmlName)2211 else:2212 imgHtml = ""2213 return imgHtml2214 def highlightFilename(self, screenshotFilename):2215 self._highlightCounter += 12216 retval = screenshotFilename + "." + str(self._highlightCounter).zfill(5) + ".png"2217 return retval2218 def changeCodeName(self, func, newName):2219 c = func.func_code2220 func.func_name = newName2221 func.func_code = types.CodeType(2222 c.co_argcount, c.co_nlocals, c.co_stacksize, c.co_flags,2223 c.co_code, c.co_consts, c.co_names, c.co_varnames,...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3#4# ==============================================================================5# PAQUETE: canaima-semilla6# ARCHIVO: scripts/c-s.sh7# DESCRIPCIÓN: Script principal. Se encarga de invocar a los demás módulos y8# funciones según los parámetros proporcionados.9# USO: ./c-s.sh [MÓDULO] [PARÁMETROS] [...]10# COPYRIGHT:11# (C) 2010-2012 Luis Alejandro Martínez Faneyth <luis@huntingbears.com.ve>12# (C) 2012 Niv Sardi <xaiki@debian.org>13# LICENCIA: GPL-314# ==============================================================================15#16# This program is free software: you can redistribute it and/or modify17# it under the terms of the GNU General Public License as published by18# the Free Software Foundation, either version 3 of the License, or19# (at your option) any later version.20#21# This program is distributed in the hope that it will be useful,22# but WITHOUT ANY WARRANTY; without even the implied warranty of23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the24# COPYING file for more details.25#26# You should have received a copy of the GNU General Public License27# along with this program. If not, see <http://www.gnu.org/licenses/>.28#29# CODE IS POETRY30# Librerías Globales31import gtk, sys32# Librerías Locales33from canaimasemilla.translator import *34from canaimasemilla.config import *35from canaimasemilla.constructor import *36from canaimasemilla.processor import *37class Main():38 def __init__(self):39 # Creating Window40 self.window, self.outbox , self.inbox = WindowContainer(41 c = self, title = MAIN_TITLE, outpad = 0, inpad = 10,42 spacing = 043 )44 # Creating Objects45 self.banner = Banner(46 c = self, box = self.outbox, image = BANNER_IMAGE47 )48 self.outbox.pack_start(gtk.HBox(), False, False, 10)49 self.row_1 = CustomBox(50 c = self, box = self.inbox, align = 'horizontal'51 )52 self.row_2 = CustomBox(53 c = self, box = self.inbox, align = 'horizontal'54 )55 self.create_profile = IconButton(56 c = self, box = self.row_1, icon = PROFILE_ICON,57 text_1 = MAIN_CREATE_PROFILE_TITLE, text_2 = MAIN_CREATE_PROFILE_TEXT,58 width = 330, height = 180, margin = 5, f_1 = ThreadGenerator,59 p_1 = (Profile, {}, True, self.window)60 )61 self.build_image = IconButton(62 c = self, box = self.row_1, icon = BUILD_ICON,63 text_1 = MAIN_BUILD_IMAGE_TITLE, text_2 = MAIN_BUILD_IMAGE_TEXT,64 width = 330, height = 180, margin = 5, f_1 = ThreadGenerator,65 p_1 = (Build, {}, True, self.window)66 )67 self.test_image = IconButton(68 c = self, box = self.row_2, icon = TEST_ICON,69 text_1 = MAIN_TEST_IMAGE_TITLE, text_2 = MAIN_TEST_IMAGE_TEXT,70 width = 330, height = 180, margin = 5, f_1 = ThreadGenerator,71 p_1 = (Test, {}, True, self.window)72 )73 self.save_image = IconButton(74 c = self, box = self.row_2, icon = SAVE_ICON,75 text_1 = MAIN_SAVE_IMAGE_TITLE, text_2 = MAIN_SAVE_IMAGE_TEXT,76 width = 330, height = 180, margin = 5, f_1 = ThreadGenerator,77 p_1 = (Save, {}, True, self.window)78 )79 self.outbox.pack_start(self.inbox, False, False, 0)80 self.outbox.pack_start(gtk.HBox(), False, False, 5)81 self.bottom_buttons = BottomButtons(82 c = self, box = self.outbox, width = 80, height = 30,83 fclose = gtk.main_quit, pclose = (),84 fhelp = ThreadGenerator,85 phelp = (86 ProcessGenerator, {87 'command': ['/usr/bin/yelp', DOCDIR+'/index.html']88 },89 False, False90 ),91 fabout = ThreadGenerator,92 pabout = (AboutWindow, {}, True, False)93 )94 # Showing95 self.window.add(self.outbox)96 self.window.show_all()97class Build():98 def __init__(self):99 # Creating Window100 self.window, self.outbox , self.inbox = WindowContainer(101 c = self, title = BUILD_TITLE, outpad = 0, inpad = 10,102 spacing = 5103 )104 # Creating Objects105 self.profile_list, self.profile_default = ProfileList(106 c = self, profiledir = PROFILEDIR107 )108 self.native_arch = GetArch()109 self.banner = Banner(110 c = self, box = self.outbox, image = BANNER_IMAGE111 )112 self.outbox.pack_start(gtk.HBox(), False, False, 11)113 self.profile_name_title = Title(114 c = self, box = self.inbox, text = BUILD_PROFILE_NAME_1115 )116 self.profile_name = ActiveCombo(117 c = self, box = self.inbox, combolist = self.profile_list,118 combodefault = self.profile_default, entry = False119 )120 self.profile_name_description = Description(121 c = self, box = self.inbox, text = BUILD_PROFILE_NAME_2122 )123 self.custom_separator_1 = CustomSeparator(124 c = self, box = self.inbox, align = 'horizontal'125 )126 self.profile_arch_title = Title(127 c = self, box = self.inbox, text = BUILD_PROFILE_ARCH_1128 )129 self.profile_arch = OptionList(130 c = self, box = self.inbox, optionlist = [131 BUILD_PROFILE_ARCH_AMD64, BUILD_PROFILE_ARCH_I386132 ]133 )134 self.profile_arch_description = Description(135 c = self, box = self.inbox, text = BUILD_PROFILE_ARCH_2136 )137 self.custom_separator_2 = CustomSeparator(138 c = self, box = self.inbox, align = 'horizontal'139 )140 self.profile_media_title = Title(141 c = self, box = self.inbox, text = BUILD_PROFILE_MEDIA_1142 )143 self.profile_media = OptionList(144 c = self, box = self.inbox, optionlist = [145 BUILD_PROFILE_MEDIA_ISO, BUILD_PROFILE_MEDIA_IMG,146 BUILD_PROFILE_MEDIA_HYBRID147 ]148 )149 self.profile_media_description = Description(150 c = self, box = self.inbox, text = BUILD_PROFILE_MEDIA_2151 )152 self.outbox.pack_start(self.inbox, False, False, 0)153 self.outbox.pack_start(gtk.HBox(), False, False, 55)154 self.bottom_buttons = BottomButtons(155 c = self, box = self.outbox, width = 80, height = 30,156 fclose = ThreadGenerator,157 pclose = (158 UserMessage, {159 'message': BUILD_CONFIRM_CANCEL_MSG,160 'title': BUILD_CONFIRM_CANCEL_TITLE,161 'type': gtk.MESSAGE_QUESTION,162 'buttons': gtk.BUTTONS_YES_NO,163 'c_1': gtk.RESPONSE_YES,164 'f_1': self.window.destroy, 'p_1': '',165 'c_2': gtk.RESPONSE_YES,166 'f_2': gtk.main_quit, 'p_2': ''167 },168 True, False169 ),170 fhelp = ThreadGenerator,171 phelp = (172 ProcessGenerator, {173 'command': ['/usr/bin/yelp', DOCDIR+'/index.html']174 },175 True, False176 ),177 fabout = ThreadGenerator,178 pabout = (AboutWindow, {}, True, False),179 fback = ThreadGenerator,180 pback = (181 UserMessage, {182 'message': BUILD_CONFIRM_CANCEL_MSG.format('\n\n'),183 'title': BUILD_CONFIRM_CANCEL_TITLE,184 'type': gtk.MESSAGE_QUESTION,185 'buttons': gtk.BUTTONS_YES_NO,186 'c_1': gtk.RESPONSE_YES,187 'f_1': self.window.hide, 'p_1': '',188 'c_2': gtk.RESPONSE_YES,189 'f_2': Main, 'p_2': ''190 },191 True, False192 ),193 fgo = ThreadGenerator,194 pgo = (195 UserMessage, {196 'message': BUILD_CONFIRM_OK_MSG.format('\n\n'),197 'title': BUILD_CONFIRM_OK_TITLE,198 'type': gtk.MESSAGE_QUESTION,199 'buttons': gtk.BUTTONS_YES_NO,200 'c_1': gtk.RESPONSE_YES,201 'f_1': BuildImage, 'p_1': (202 self, self.profile_name, self.profile_arch,203 self.profile_media, self.inbox204 )205 },206 True, False207 )208 )209 if self.native_arch == 'i686':210 for child in self.profile_arch:211 if child.get_label() == 'amd64':212 child.set_sensitive(False)213 # Showing214 self.window.add(self.outbox)215 self.window.show_all()216class Profile():217 def __init__(self):218 # Creating Window219 self.window, self.outbox , self.inbox = WindowContainer(220 c = self, title = BUILD_TITLE, outpad = 0, inpad = 10,221 spacing = 10222 )223 self.locale_list, self.locale_active = LocaleList(224 c = self, supported = supported_locales,225 current = os.environ['LC_ALL']226 )227 self.native_arch = GetArch()228 self.banner = Banner(229 c = self, box = self.outbox, image = BANNER_IMAGE230 )231 self.id_tab, self.distro_tab, self.misc_tab, \232 self.extrarepos_tab, self.packages_tab, self.includes_tab, \233 self.installer_tab = TabbedBox(234 c = self, box = self.inbox, pos = gtk.POS_TOP, tabs = [235 PROFILE_ID_TAB, PROFILE_DISTRO_TAB, PROFILE_MISC_TAB,236 PROFILE_EXTRAREPOS_TAB, PROFILE_PACKAGES_TAB,237 PROFILE_INCLUDES_TAB, PROFILE_INSTALLER_TAB238 ]239 )240 # ID TAB241 self.profile_name_title = Title(242 c = self, box = self.id_tab, text = PROFILE_PROFILE_NAME_1243 )244 self.profile_name = TextEntry(245 c = self, box = self.id_tab, maxlength = 1024, length = 60,246 text = default_profile_name, regex = '^[a-z-]*$'247 )248 self.profile_name_description = Description(249 c = self, box = self.id_tab, text = PROFILE_PROFILE_NAME_2250 )251 self.custom_separator_2 = CustomSeparator(252 c = self, box = self.id_tab, align = 'horizontal'253 )254 self.author_name_title = Title(255 c = self, box = self.id_tab, text = PROFILE_AUTHOR_NAME_1256 )257 self.author_name = TextEntry(258 c = self, box = self.id_tab, maxlength = 1024, length = 60,259 text = default_profile_author, regex = '^[\w\ ]*$'260 )261 self.author_name_description = Description(262 c = self, box = self.id_tab, text = PROFILE_AUTHOR_NAME_2263 )264 self.custom_separator_3 = CustomSeparator(265 c = self, box = self.id_tab, align = 'horizontal'266 )267 self.author_email_title = Title(268 c = self, box = self.id_tab, text = PROFILE_AUTHOR_EMAIL_1269 )270 self.author_email = TextEntry(271 c = self, box = self.id_tab, maxlength = 1024, length = 60,272 text = default_profile_email, regex = '^[_.@0-9A-Za-z-]*$'273 )274 self.author_email_description = Description(275 c = self, box = self.id_tab, text = PROFILE_AUTHOR_EMAIL_2276 )277 self.custom_separator_4 = CustomSeparator(278 c = self, box = self.id_tab, align = 'horizontal'279 )280 self.author_url_title = Title(281 c = self, box = self.id_tab, text = PROFILE_AUTHOR_URL_1282 )283 self.author_url = TextEntry(284 c = self, box = self.id_tab, maxlength = 1024, length = 60,285 text = default_profile_url, regex = '^[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*$'286 )287 self.author_url_description = Description(288 c = self, box = self.id_tab, text = PROFILE_AUTHOR_URL_2289 )290 # DISTRO TAB291 self.meta_dist_title = Title(292 c = self, box = self.distro_tab, text = PROFILE_META_DIST_1293 )294 self.meta_box = CustomBox(295 c = self, box = self.distro_tab, align = 'horizontal'296 )297 self.meta_box.set_spacing(5)298 self.meta_dist_box = CustomBox(299 c = self, box = self.meta_box, align = 'horizontal'300 )301 self.meta_codename_box = CustomBox(302 c = self, box = self.meta_box, align = 'horizontal'303 )304 self.meta_dist_description = Description(305 c = self, box = self.distro_tab, text = PROFILE_META_DIST_2306 )307 self.meta_dist = gtk.combo_box_new_text()308 self.meta_dist.append_text('canaima')309 self.meta_dist.set_active(0)310 self.codename_list, self.codename_active = CodenameList(311 c = self, dist = self.meta_dist, db = apt_templates312 )313 self.meta_codename = ActiveCombo(314 c = self, box = self.meta_codename_box, combolist = self.codename_list,315 combodefault = self.codename_active, entry = True316 )317 self.custom_separator_7 = CustomSeparator(318 c = self, box = self.distro_tab, align = 'horizontal'319 )320 self.meta_repo_title = Title(321 c = self, box = self.distro_tab, text = PROFILE_META_REPO_1322 )323 self.meta_repo = TextEntry(324 c = self, box = self.distro_tab, maxlength = 1024, length = 60,325 text = canaima_repo, regex = '^[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*$'326 )327 self.meta_repo_description = Description(328 c = self, box = self.distro_tab, text = PROFILE_META_REPO_2329 )330 self.custom_separator_9 = CustomSeparator(331 c = self, box = self.distro_tab, align = 'horizontal'332 )333 self.meta_reposections_title = Title(334 c = self, box = self.distro_tab, text = PROFILE_META_REPOSECTIONS_1335 )336 self.section_list = SectionList(c = self, dist = self.meta_dist)337 self.meta_reposections = CheckList(338 c = self, box = self.distro_tab, checklist = self.section_list,339 checkdefault = 'main'340 )341 self.meta_dist = ActiveCombo(342 c = self, box = self.meta_dist_box, combolist = cs_distros,343 combodefault = 2, entry = False,344 f_1 = ChangeCodename,345 p_1 = (self, self.meta_codename, apt_templates),346 f_2 = ChangeRepo,347 p_2 = (self, self.meta_repo),348 f_3 = ChangeSections,349 p_3 = (self, self.meta_reposections)350 )351 self.meta_reposections_description = Description(352 c = self, box = self.distro_tab, text = PROFILE_META_REPOSECTIONS_2353 )354 # MISC TAB355 self.profile_arch_title = Title(356 c = self, box = self.misc_tab, text = PROFILE_PROFILE_ARCH_1357 )358 self.profile_arch = CheckList(359 c = self, box = self.misc_tab, checklist = supported_arch,360 checkdefault = ''361 )362 self.profile_arch_description = Description(363 c = self, box = self.misc_tab, text = PROFILE_PROFILE_ARCH_2364 )365 self.custom_separator_1 = CustomSeparator(366 c = self, box = self.misc_tab, align = 'horizontal'367 )368 self.os_locale_title = Title(369 c = self, box = self.misc_tab, text = PROFILE_OS_LOCALE_1370 )371 self.os_locale = ActiveCombo(372 c = self, box = self.misc_tab, combolist = self.locale_list,373 combodefault = self.locale_active, entry = False374 )375 self.os_locale_description = Description(376 c = self, box = self.misc_tab, text = PROFILE_OS_LOCALE_2377 )378 self.custom_separator_6 = CustomSeparator(379 c = self, box = self.misc_tab, align = 'horizontal'380 )381 self.img_syslinux_splash_title = Title(382 c = self, box = self.misc_tab, text = PROFILE_IMG_SYSLINUX_SPLASH_1383 )384 self.img_syslinux_splash_box = CustomBox(385 c = self, box = self.misc_tab, align = 'horizontal'386 )387 self.img_syslinux_splash = TextEntry(388 c = self, box = self.img_syslinux_splash_box, maxlength = 1024,389 length = 68, text = PROFILE_IMG_SYSLINUX_SPLASH_ENTRY, regex = '^.*$'390 )391 self.img_syslinux_splash_choose = ActiveButton(392 c = self, box = self.img_syslinux_splash_box, text = gtk.STOCK_OPEN,393 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (394 UserSelect, {395 'c': self,396 'title': PROFILE_IMG_SYSLINUX_SPLASH_SELECT_TITLE,397 'action': gtk.FILE_CHOOSER_ACTION_OPEN,398 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,399 'filter': {400 'name': PROFILE_MIMETYPE_PNG_NAME,401 'mimetypes': ('image/png',)402 },403 'entry': self.img_syslinux_splash404 },405 True, False406 )407 )408 self.img_syslinux_splash_clean = ActiveButton(409 c = self, box = self.img_syslinux_splash_box, text = gtk.STOCK_CLEAR,410 width = 0, height = 0, f_1 = CleanEntry,411 p_1 = (self.img_syslinux_splash,)412 )413 self.img_syslinux_splash_description = Description(414 c = self, box = self.misc_tab, text = PROFILE_IMG_SYSLINUX_SPLASH_2415 )416 # EXTRAREPOS TAB417 self.os_extrarepos_box_1 = CustomBox(418 c = self, box = self.extrarepos_tab, align = 'horizontal'419 )420 self.os_extrarepos_box_2 = CustomBox(421 c = self, box = self.extrarepos_tab, align = 'horizontal'422 )423 self.os_extrarepos_box_3 = CustomBox(424 c = self, box = self.extrarepos_tab, align = 'horizontal'425 )426 self.os_extrarepos_check = ActiveCheck(427 c = self, box = self.os_extrarepos_box_1,428 text = PROFILE_OS_EXTRAREPOS_CHECK, active = False,429 f_1 = Toggle, p_1 = (self.os_extrarepos_box_2,),430 f_2 = Toggle, p_2 = (self.os_extrarepos_box_3,)431 )432 self.os_extrarepos = ScrolledFrame(433 c = self, box = self.os_extrarepos_box_2434 )435 self.os_extrarepos_url = TextEntry(436 c = self, box = self.os_extrarepos_box_3,437 maxlength = 1024, length = 38, text = PROFILE_OS_EXTRAREPOS_URL,438 regex = '^[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*$'439 )440 self.os_extrarepos_branch = TextEntry(441 c = self, box = self.os_extrarepos_box_3,442 maxlength = 1024, length = 10, text = PROFILE_OS_EXTRAREPOS_BRANCH,443 regex = '^[A-Za-z0-9-]*$'444 )445 self.os_extrarepos_sections = TextEntry(446 c = self, box = self.os_extrarepos_box_3,447 maxlength = 1024, length = 17, text = PROFILE_OS_EXTRAREPOS_SECTIONS,448 regex = '^[A-Za-z0-9\ -]*$'449 )450 self.os_extrarepos_add = ActiveButton(451 c = self, box = self.os_extrarepos_box_3, text = gtk.STOCK_ADD,452 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (453 AddExtraRepos, {454 'c': self,455 'url_entry': self.os_extrarepos_url,456 'branch_entry': self.os_extrarepos_branch,457 'sections_entry': self.os_extrarepos_sections,458 'arch_container': self.profile_arch,459 'repolistframe': self.os_extrarepos,460 },461 False, False462 )463 )464 self.os_extrarepos_clean = ActiveButton(465 c = self, box = self.os_extrarepos_box_3, text = gtk.STOCK_CLEAR,466 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.os_extrarepos,)467 )468 self.os_extrarepos_description = Description(469 c = self, box = self.extrarepos_tab, text = PROFILE_OS_EXTRAREPOS_2470 )471 # PACKAGES TAB472 self.os_packages_title = Title(473 c = self, box = self.packages_tab, text = PROFILE_OS_PACKAGES_1474 )475 self.os_packages_box_1 = CustomBox(476 c = self, box = self.packages_tab, align = 'horizontal'477 )478 self.os_packages_box_2 = CustomBox(479 c = self, box = self.packages_tab, align = 'horizontal'480 )481 self.os_packages = ScrolledFrame(482 c = self, box = self.os_packages_box_1483 )484 self.os_packages_name = TextEntry(485 c = self, box = self.os_packages_box_2,486 maxlength = 1024, length = 68, text = PROFILE_OS_PACKAGES_ENTRY,487 regex = '^[A-Za-z0-9\ -]*$'488 )489 self.os_packages_add = ActiveButton(490 c = self, box = self.os_packages_box_2, text = gtk.STOCK_ADD,491 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (492 AddPackages, {493 'c': self,494 'url_entry': self.meta_repo,495 'branch_entry': self.meta_codename,496 'section_container': self.meta_reposections,497 'arch_container': self.profile_arch,498 'extrareposframe': self.os_extrarepos,499 'packages_entry': self.os_packages_name,500 'packageslistframe': self.os_packages,501 },502 False, False503 )504 )505 self.os_packages_clean = ActiveButton(506 c = self, box = self.os_packages_box_2, text = gtk.STOCK_CLEAR,507 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.os_packages,),508 )509 self.os_packages_description = Description(510 c = self, box = self.packages_tab, text = PROFILE_OS_PACKAGES_2511 )512 self.custom_separator_12 = CustomSeparator(513 c = self, box = self.packages_tab, align = 'horizontal'514 )515 self.img_pool_packages_title = Title(516 c = self, box = self.packages_tab, text = PROFILE_IMG_POOL_PACKAGES_1517 )518 self.img_pool_packages_box_1 = CustomBox(519 c = self, box = self.packages_tab, align = 'horizontal'520 )521 self.img_pool_packages_box_2 = CustomBox(522 c = self, box = self.packages_tab, align = 'horizontal'523 )524 self.img_pool_packages = ScrolledFrame(525 c = self, box = self.img_pool_packages_box_1526 )527 self.img_pool_packages_name = TextEntry(528 c = self, box = self.img_pool_packages_box_2,529 maxlength = 1024, length = 68,530 text = PROFILE_IMG_POOL_PACKAGES_ENTRY, regex = '^[A-Za-z0-9\ -]*$'531 )532 self.img_pool_packages_add = ActiveButton(533 c = self, box = self.img_pool_packages_box_2, text = gtk.STOCK_ADD,534 width = 0, height = 0,f_1 = ThreadGenerator, p_1 = (535 AddPackages, {536 'c': self,537 'url_entry': self.meta_repo,538 'branch_entry': self.meta_codename,539 'section_container': self.meta_reposections,540 'arch_container': self.profile_arch,541 'extrareposframe': self.os_extrarepos,542 'packages_entry': self.img_pool_packages_name,543 'packageslistframe': self.img_pool_packages,544 },545 False, False546 )547 )548 self.img_pool_packages_clean = ActiveButton(549 c = self, box = self.img_pool_packages_box_2, text = gtk.STOCK_CLEAR,550 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.img_pool_packages,),551 )552 self.img_pool_packages_description = Description(553 c = self, box = self.packages_tab, text = PROFILE_IMG_POOL_PACKAGES_2554 )555 # INCLUDES TAB556 self.os_includes_title = Title(557 c = self, box = self.includes_tab, text = PROFILE_OS_INCLUDES_1558 )559 self.os_includes_box = CustomBox(560 c = self, box = self.includes_tab, align = 'horizontal'561 )562 self.os_includes = TextEntry(563 c = self, box = self.os_includes_box, maxlength = 1024, length = 68,564 text = PROFILE_OS_INCLUDES_ENTRY, regex = '^.*$'565 )566 self.os_includes_choose = ActiveButton(567 c = self, box = self.os_includes_box, text = gtk.STOCK_OPEN,568 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (569 UserSelect, {570 'c': self,571 'title': PROFILE_OS_INCLUDES_SELECT_TITLE,572 'action': gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,573 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,574 'filter': {575 'name': PROFILE_MIMETYPE_FOLDER_NAME,576 'mimetypes': ('application/x-directory',)577 },578 'entry': self.os_includes579 },580 True, False581 )582 )583 self.os_includes_clean = ActiveButton(584 c = self, box = self.os_includes_box, text = gtk.STOCK_CLEAR,585 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.os_includes,),586 )587 self.os_includes_description = Description(588 c = self, box = self.includes_tab, text = PROFILE_OS_INCLUDES_2589 )590 self.custom_separator_14 = CustomSeparator(591 c = self, box = self.includes_tab, align = 'horizontal'592 )593 self.img_includes_title = Title(594 c = self, box = self.includes_tab, text = PROFILE_IMG_INCLUDES_1595 )596 self.img_includes_box = CustomBox(597 c = self, box = self.includes_tab, align = 'horizontal'598 )599 self.img_includes = TextEntry(600 c = self, box = self.img_includes_box, maxlength = 1024, length = 68,601 text = PROFILE_IMG_INCLUDES_ENTRY, regex = '^.*$'602 )603 self.img_includes_choose = ActiveButton(604 c = self, box = self.img_includes_box, text = gtk.STOCK_OPEN,605 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (606 UserSelect, {607 'c': self,608 'title': PROFILE_IMG_INCLUDES_SELECT_TITLE,609 'action': gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,610 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,611 'filter': {612 'name': PROFILE_MIMETYPE_FOLDER_NAME,613 'mimetypes': ('application/x-directory',)614 },615 'entry': self.img_includes616 },617 True, False618 )619 )620 self.img_includes_clean = ActiveButton(621 c = self, box = self.img_includes_box, text = gtk.STOCK_CLEAR,622 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.img_includes,),623 )624 self.img_includes_description = Description(625 c = self, box = self.includes_tab, text = PROFILE_IMG_INCLUDES_2626 )627 self.custom_separator_15 = CustomSeparator(628 c = self, box = self.includes_tab, align = 'horizontal'629 )630 self.os_hooks_title = Title(631 c = self, box = self.includes_tab, text = PROFILE_OS_HOOKS_1632 )633 self.os_hooks_box = CustomBox(634 c = self, box = self.includes_tab, align = 'horizontal'635 )636 self.os_hooks = TextEntry(637 c = self, box = self.os_hooks_box, maxlength = 1024, length = 68,638 text = PROFILE_OS_HOOKS_ENTRY, regex = '^.*$'639 )640 self.os_hooks_choose = ActiveButton(641 c = self, box = self.os_hooks_box, text = gtk.STOCK_OPEN,642 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (643 UserSelect, {644 'c': self,645 'title': PROFILE_OS_HOOKS_SELECT_TITLE,646 'action': gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,647 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,648 'filter': {649 'name': PROFILE_MIMETYPE_FOLDER_NAME,650 'mimetypes': ('application/x-directory',)651 },652 'entry': self.os_hooks653 },654 True, False655 )656 )657 self.os_hooks_clean = ActiveButton(658 c = self, box = self.os_hooks_box, text = gtk.STOCK_CLEAR,659 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.os_hooks,),660 )661 self.os_hooks_description = Description(662 c = self, box = self.includes_tab, text = PROFILE_OS_HOOKS_2663 )664 self.custom_separator_16 = CustomSeparator(665 c = self, box = self.includes_tab, align = 'horizontal'666 )667 self.img_hooks_title = Title(668 c = self, box = self.includes_tab, text = PROFILE_IMG_HOOKS_1669 )670 self.img_hooks_box = CustomBox(671 c = self, box = self.includes_tab, align = 'horizontal'672 )673 self.img_hooks = TextEntry(674 c = self, box = self.img_hooks_box, maxlength = 1024, length = 68,675 text = PROFILE_IMG_HOOKS_ENTRY, regex = '^.*$'676 )677 self.img_hooks_choose = ActiveButton(678 c = self, box = self.img_hooks_box, text = gtk.STOCK_OPEN,679 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (680 UserSelect, {681 'c': self,682 'title': PROFILE_IMG_HOOKS_SELECT_TITLE,683 'action': gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,684 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,685 'filter': {686 'name': PROFILE_MIMETYPE_FOLDER_NAME,687 'mimetypes': ('application/x-directory',)688 },689 'entry': self.img_hooks690 },691 True, False692 )693 )694 self.img_hooks_clean = ActiveButton(695 c = self, box = self.img_hooks_box, text = gtk.STOCK_CLEAR,696 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.img_hooks,),697 )698 self.img_hooks_description = Description(699 c = self, box = self.includes_tab, text = PROFILE_IMG_HOOKS_2700 )701 # INSTALLER TAB702 self.img_debian_installer_box_1 = CustomBox(703 c = self, box = self.installer_tab, align = 'vertical'704 )705 self.img_debian_installer_box_2 = CustomBox(706 c = self, box = self.installer_tab, align = 'vertical'707 )708 self.img_debian_installer_check = ActiveCheck(709 c = self, box = self.img_debian_installer_box_1,710 text = PROFILE_IMG_DEBIAN_INSTALLER_CHECK, active = False,711 f_1 = Toggle, p_1 = (self.img_debian_installer_box_2,),712 )713 self.img_debian_installer_banner_title = Title(714 c = self, box = self.img_debian_installer_box_2,715 text = PROFILE_IMG_DEBIAN_INSTALLER_BANNER_1716 )717 self.img_debian_installer_banner_box = CustomBox(718 c = self, box = self.img_debian_installer_box_2, align = 'horizontal'719 )720 self.img_debian_installer_banner = TextEntry(721 c = self, box = self.img_debian_installer_banner_box,722 maxlength = 1024, length = 68,723 text = PROFILE_IMG_DEBIAN_INSTALLER_BANNER_ENTRY, regex = '^.*$'724 )725 self.img_debian_installer_banner_choose = ActiveButton(726 c = self, box = self.img_debian_installer_banner_box,727 text = gtk.STOCK_OPEN, width = 0, height = 0, f_1 = ThreadGenerator,728 p_1 = (729 UserSelect, {730 'c': self,731 'title': PROFILE_IMG_DEBIAN_INSTALLER_BANNER_SELECT_TITLE,732 'action': gtk.FILE_CHOOSER_ACTION_OPEN,733 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,734 'filter': {735 'name': PROFILE_MIMETYPE_PNG_NAME,736 'mimetypes': ('image/png',)737 },738 'entry': self.img_debian_installer_banner739 },740 True, False741 )742 )743 self.img_debian_installer_banner_clean = ActiveButton(744 c = self, box = self.img_debian_installer_banner_box,745 text = gtk.STOCK_CLEAR, width = 0, height = 0,746 f_1 = CleanEntry, p_1 = (self.img_debian_installer_banner,),747 )748 self.img_debian_installer_preseed_title = Title(749 c = self, box = self.img_debian_installer_box_2,750 text = PROFILE_IMG_DEBIAN_INSTALLER_PRESEED_1751 )752 self.img_debian_installer_preseed_box = CustomBox(753 c = self, box = self.img_debian_installer_box_2, align = 'horizontal'754 )755 self.img_debian_installer_preseed = TextEntry(756 c = self, box = self.img_debian_installer_preseed_box,757 maxlength = 1024, length = 68,758 text = PROFILE_IMG_DEBIAN_INSTALLER_PRESEED_ENTRY, regex = '^.*$'759 )760 self.img_debian_installer_preseed_choose = ActiveButton(761 c = self, box = self.img_debian_installer_preseed_box,762 text = gtk.STOCK_OPEN, width = 0, height = 0, f_1 = ThreadGenerator,763 p_1 = (764 UserSelect, {765 'c': self,766 'title': PROFILE_IMG_DEBIAN_INSTALLER_PRESEED_SELECT_TITLE,767 'action': gtk.FILE_CHOOSER_ACTION_OPEN,768 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,769 'entry': self.img_debian_installer_preseed770 },771 True, False772 )773 )774 self.img_debian_installer_preseed_clean = ActiveButton(775 c = self, box = self.img_debian_installer_preseed_box,776 text = gtk.STOCK_CLEAR, width = 0, height = 0, f_1 = CleanEntry,777 p_1 = (self.img_debian_installer_preseed,),778 )779 self.img_debian_installer_gtk_title = Title(780 c = self, box = self.img_debian_installer_box_2,781 text = PROFILE_IMG_DEBIAN_INSTALLER_GTK_1782 )783 self.img_debian_installer_gtk_box = CustomBox(784 c = self, box = self.img_debian_installer_box_2, align = 'horizontal'785 )786 self.img_debian_installer_gtk = TextEntry(787 c = self, box = self.img_debian_installer_gtk_box,788 maxlength = 1024, length = 68,789 text = PROFILE_IMG_DEBIAN_INSTALLER_GTK_ENTRY, regex = '^.*$'790 )791 self.img_debian_installer_gtk_choose = ActiveButton(792 c = self, box = self.img_debian_installer_gtk_box,793 text = gtk.STOCK_OPEN, width = 0, height = 0, f_1 = ThreadGenerator,794 p_1 = (795 UserSelect, {796 'c': self,797 'title': PROFILE_IMG_DEBIAN_INSTALLER_GTK_SELECT_TITLE,798 'action': gtk.FILE_CHOOSER_ACTION_OPEN,799 'allfiltertitle': PROFILE_MIMETYPE_ALL_NAME,800 'entry': self.img_debian_installer_gtk801 },802 True, False803 )804 )805 self.img_debian_installer_gtk_clean = ActiveButton(806 c = self, box = self.img_debian_installer_gtk_box,807 text = gtk.STOCK_CLEAR, width = 0, height = 0,808 f_1 = CleanEntry, p_1 = (self.img_debian_installer_gtk,),809 )810 self.img_debian_installer_description = Description(811 c = self, box = self.installer_tab,812 text = PROFILE_IMG_DEBIAN_INSTALLER_2813 )814 self.outbox.pack_start(self.inbox, False, False, 0)815 self.outbox.pack_start(gtk.HBox(), False, False, 5)816 self.bottom_buttons = BottomButtons(817 c = self, box = self.outbox, width = 80, height = 30,818 fclose = ThreadGenerator,819 pclose = (820 UserMessage, {821 'message': PROFILE_CONFIRM_CANCEL_MSG.format('\n\n'),822 'title': PROFILE_CONFIRM_CANCEL_TITLE,823 'type': gtk.MESSAGE_QUESTION,824 'buttons': gtk.BUTTONS_YES_NO,825 'c_1': gtk.RESPONSE_YES,826 'f_1': self.window.destroy, 'p_1': '',827 'c_2': gtk.RESPONSE_YES,828 'f_2': gtk.main_quit, 'p_2': ''829 },830 True, False831 ),832 fhelp = ThreadGenerator,833 phelp = (834 ProcessGenerator, {835 'command': ['/usr/bin/yelp', DOCDIR+'/index.html']836 },837 True, False838 ),839 fabout = ThreadGenerator,840 pabout = (AboutWindow, {}, True, False),841 fback = ThreadGenerator,842 pback = (843 UserMessage, {844 'message': PROFILE_CONFIRM_CANCEL_MSG.format('\n\n'),845 'title': PROFILE_CONFIRM_CANCEL_TITLE,846 'type': gtk.MESSAGE_QUESTION,847 'buttons': gtk.BUTTONS_YES_NO,848 'c_1': gtk.RESPONSE_YES,849 'f_1': self.window.hide, 'p_1': '',850 'c_2': gtk.RESPONSE_YES,851 'f_2': Main, 'p_2': ''852 },853 True, False854 ),855 fgo = ThreadGenerator,856 pgo = (857 UserMessage, {858 'message': PROFILE_CONFIRM_OK_MSG.format('\n\n'),859 'title': PROFILE_CONFIRM_OK_TITLE,860 'type': gtk.MESSAGE_QUESTION,861 'buttons': gtk.BUTTONS_YES_NO,862 'c_1': gtk.RESPONSE_YES,863 'f_1': CreateProfile, 'p_1': (864 self, self.profile_name, self.profile_arch,865 self.author_name, self.author_email, self.author_url,866 self.os_locale, self.meta_dist, self.meta_codename,867 self.meta_repo, self.meta_reposections, self.os_extrarepos,868 self.os_packages, self.img_pool_packages, self.os_includes,869 self.img_includes, self.os_hooks, self.img_hooks,870 self.img_syslinux_splash, self.img_debian_installer_check,871 self.img_debian_installer_banner,872 self.img_debian_installer_preseed,873 self.img_debian_installer_gtk874 )875 },876 True, False877 )878 )879 if self.native_arch == 'i686':880 for child in self.profilearch:881 if child.get_label() == 'amd64':882 child.set_sensitive(False)883 Toggle(self, self.os_extrarepos_box_2)884 Toggle(self, self.os_extrarepos_box_3)885 Toggle(self, self.img_debian_installer_box_2)886 # Showing887 self.window.add(self.outbox)888 self.window.show_all()889class Test():890 def __init__(self):891 # Creating Window892 self.window, self.outbox , self.inbox = WindowContainer(893 c = self, title = TEST_TITLE, outpad = 0, inpad = 10,894 spacing = 5895 )896 self.free_disk = GetFreeDisk()897 self.free_ram = GetFreeRam()898 self.processors = GetProcessors()899 # Creating Objects900 self.banner = Banner(901 c = self, box = self.outbox, image = BANNER_IMAGE902 )903 self.outbox.pack_start(gtk.HBox(), False, False, 5)904 self.test_image_title = Title(905 c = self, box = self.inbox, text = TEST_IMAGE_1906 )907 self.test_image_box = CustomBox(908 c = self, box = self.inbox, align = 'horizontal'909 )910 self.test_image = TextEntry(911 c = self, box = self.test_image_box, maxlength = 1024, length = 68,912 text = TEST_IMAGE_ENTRY, regex = '^.*$'913 )914 self.test_image_choose = ActiveButton(915 c = self, box = self.test_image_box, text = gtk.STOCK_OPEN,916 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (917 UserSelect, {918 'c': self,919 'title': TEST_IMAGE_SELECT_TITLE,920 'action': gtk.FILE_CHOOSER_ACTION_OPEN,921 'allfiltertitle': TEST_MIMETYPE_ALL_NAME,922 'filter': {923 'name': TEST_MIMETYPE_ISO_NAME,924 'mimetypes': ('application/octet-stream',)925 },926 'entry': self.test_image927 },928 True, False929 )930 )931 self.test_image_clean = ActiveButton(932 c = self, box = self.test_image_box, text = gtk.STOCK_CLEAR,933 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.test_image,),934 )935 self.test_image_description = Description(936 c = self, box = self.inbox, text = TEST_IMAGE_2937 )938 self.custom_separator_1 = CustomSeparator(939 c = self, box = self.inbox, align = 'horizontal'940 )941 self.test_memory_title = Title(942 c = self, box = self.inbox, text = TEST_MEMORY_1943 )944 self.test_memory = NumericSelector(945 c = self, box = self.inbox, init = 256.0, lower = 256.0,946 upper = self.free_ram, inc_1 = 10.0, inc_2 = 100.0947 )948 self.test_memory_description = Description(949 c = self, box = self.inbox, text = TEST_MEMORY_2950 )951 self.custom_separator_2 = CustomSeparator(952 c = self, box = self.inbox, align = 'horizontal'953 )954 self.test_processors_title = Title(955 c = self, box = self.inbox, text = TEST_PROCESSORS_1956 )957 self.test_processors = NumericSelector(958 c = self, box = self.inbox, init = 1.0, lower = 1.0,959 upper = self.processors, inc_1 = 1.0, inc_2 = 1.0960 )961 self.test_processors_description = Description(962 c = self, box = self.inbox, text = TEST_PROCESSORS_2963 )964 self.custom_separator_3 = CustomSeparator(965 c = self, box = self.inbox, align = 'horizontal'966 )967 self.test_start_title = Title(968 c = self, box = self.inbox, text = TEST_START_1969 )970 self.test_start = OptionList(971 c = self, box = self.inbox, optionlist = [972 TEST_START_CD_LABEL, TEST_START_HD_LABEL973 ]974 )975 self.test_start_description = Description(976 c = self, box = self.inbox, text = TEST_START_2977 )978 self.custom_separator_4 = CustomSeparator(979 c = self, box = self.inbox, align = 'horizontal'980 )981 self.test_disk_box_1 = CustomBox(982 c = self, box = self.inbox, align = 'horizontal'983 )984 self.test_disk_box_2 = CustomBox(985 c = self, box = self.inbox, align = 'horizontal'986 )987 self.test_disk = NumericSelector(988 c = self, box = self.test_disk_box_2, init = 10.0, lower = 5.0,989 upper = self.free_disk, inc_1 = 1.0, inc_2 = 10.0990 )991 self.test_disk_check = ActiveCheck(992 c = self, box = self.test_disk_box_1, text = TEST_DISK_CHECK_LABEL,993 active = False, f_1 = Toggle, p_1 = (self.test_disk_box_2,),994 )995 self.outbox.pack_start(self.inbox, False, False, 0)996 self.bottom_buttons = BottomButtons(997 c = self, box = self.outbox, width = 80, height = 30,998 fclose = ThreadGenerator,999 pclose = (1000 UserMessage, {1001 'message': TEST_CONFIRM_CANCEL_MSG.format('\n\n'),1002 'title': TEST_CONFIRM_CANCEL_TITLE,1003 'type': gtk.MESSAGE_QUESTION,1004 'buttons': gtk.BUTTONS_YES_NO,1005 'c_1': gtk.RESPONSE_YES,1006 'f_1': self.window.destroy, 'p_1': '',1007 'c_2': gtk.RESPONSE_YES,1008 'f_2': gtk.main_quit, 'p_2': ''1009 },1010 True, False1011 ),1012 fhelp = ThreadGenerator,1013 phelp = (1014 ProcessGenerator, {1015 'command': ['/usr/bin/yelp', DOCDIR+'/index.html']1016 },1017 True, False1018 ),1019 fabout = ThreadGenerator,1020 pabout = (AboutWindow, {}, True, False),1021 fback = ThreadGenerator,1022 pback = (1023 UserMessage, {1024 'message': TEST_CONFIRM_CANCEL_MSG.format('\n\n'),1025 'title': TEST_CONFIRM_CANCEL_TITLE,1026 'type': gtk.MESSAGE_QUESTION,1027 'buttons': gtk.BUTTONS_YES_NO,1028 'c_1': gtk.RESPONSE_YES,1029 'f_1': self.window.hide, 'p_1': '',1030 'c_2': gtk.RESPONSE_YES,1031 'f_2': Main, 'p_2': ''1032 },1033 True, False1034 ),1035 fgo = ThreadGenerator,1036 pgo = (1037 UserMessage, {1038 'message': TEST_CONFIRM_OK_MSG.format('\n\n'),1039 'title': TEST_CONFIRM_OK_TITLE,1040 'type': gtk.MESSAGE_QUESTION,1041 'buttons': gtk.BUTTONS_YES_NO,1042 'c_1': gtk.RESPONSE_YES,1043 'f_1': TestImage, 'p_1': (1044 self, self.test_image, self.test_memory,1045 self.test_processors, self.test_start1046 )1047 },1048 True, False1049 )1050 )1051 Toggle(self, self.test_disk_box_2)1052 self.window.add(self.outbox)1053 self.window.show_all()1054class Save():1055 def __init__(self):1056 # Creating Window1057 self.window, self.outbox , self.inbox = WindowContainer(1058 c = self, title = SAVE_TITLE, outpad = 0, inpad = 10,1059 spacing = 51060 )1061 self.available_drives = GetWritableDrives()1062 # Creating Objects1063 self.banner = Banner(1064 c = self, box = self.outbox, image = BANNER_IMAGE1065 )1066 self.outbox.pack_start(gtk.HBox(), False, False, 10)1067 self.save_device_title = Title(1068 c = self, box = self.inbox, text = SAVE_DEVICE_11069 )1070 self.save_device = ActiveCombo(1071 c = self, box = self.inbox, combolist = self.available_drives,1072 combodefault = 0, entry = True1073 )1074 self.save_device_description = Description(1075 c = self, box = self.inbox, text = SAVE_DEVICE_21076 )1077 self.custom_separator_1 = CustomSeparator(1078 c = self, box = self.inbox, align = 'horizontal'1079 )1080 self.save_image_title = Title(1081 c = self, box = self.inbox, text = SAVE_IMAGE_11082 )1083 self.save_image_box = CustomBox(1084 c = self, box = self.inbox, align = 'horizontal'1085 )1086 self.save_image = TextEntry(1087 c = self, box = self.save_image_box, maxlength = 1024, length = 68,1088 text = SAVE_IMAGE_ENTRY, regex = '^.*$'1089 )1090 self.save_image_choose = ActiveButton(1091 c = self, box = self.save_image_box, text = gtk.STOCK_OPEN,1092 width = 0, height = 0, f_1 = ThreadGenerator, p_1 = (1093 UserSelect, {1094 'c': self,1095 'title': SAVE_IMAGE_SELECT_TITLE,1096 'action': gtk.FILE_CHOOSER_ACTION_OPEN,1097 'allfiltertitle': SAVE_MIMETYPE_ALL_NAME,1098 'filter': {1099 'name': SAVE_MIMETYPE_ISO_NAME,1100 'mimetypes': ('application/octet-stream',)1101 },1102 'entry': self.save_image1103 },1104 True, False1105 )1106 )1107 self.save_image_clean = ActiveButton(1108 c = self, box = self.save_image_box, text = gtk.STOCK_CLEAR,1109 width = 0, height = 0, f_1 = CleanEntry, p_1 = (self.save_image,),1110 )1111 self.save_image_description = Description(1112 c = self, box = self.inbox, text = SAVE_IMAGE_21113 )1114 self.outbox.pack_start(self.inbox, False, False, 0)1115 self.outbox.pack_start(gtk.HBox(), False, False, 110)1116 self.bottombuttons = BottomButtons(1117 c = self, box = self.outbox, width = 80, height = 30,1118 fclose = ThreadGenerator,1119 pclose = (1120 UserMessage, {1121 'message': SAVE_CONFIRM_CANCEL_MSG.format('\n\n'),1122 'title': SAVE_CONFIRM_CANCEL_TITLE,1123 'type': gtk.MESSAGE_QUESTION,1124 'buttons': gtk.BUTTONS_YES_NO,1125 'c_1': gtk.RESPONSE_YES,1126 'f_1': self.window.destroy, 'p_1': '',1127 'c_2': gtk.RESPONSE_YES,1128 'f_2': gtk.main_quit, 'p_2': ''1129 },1130 True, False1131 ),1132 fhelp = ThreadGenerator,1133 phelp = (1134 ProcessGenerator, {1135 'command': ['/usr/bin/yelp', DOCDIR+'/index.html']1136 },1137 True, False1138 ),1139 fabout = ThreadGenerator,1140 pabout = (AboutWindow, {}, True, False),1141 fback = ThreadGenerator,1142 pback = (1143 UserMessage, {1144 'message': SAVE_CONFIRM_CANCEL_MSG.format('\n\n'),1145 'title': SAVE_CONFIRM_CANCEL_TITLE,1146 'type': gtk.MESSAGE_QUESTION,1147 'buttons': gtk.BUTTONS_YES_NO,1148 'c_1': gtk.RESPONSE_YES,1149 'f_1': self.window.hide, 'p_1': '',1150 'c_2': gtk.RESPONSE_YES,1151 'f_2': Main, 'p_2': ''1152 },1153 True, False1154 ),1155 fgo = ThreadGenerator,1156 pgo = (1157 UserMessage, {1158 'message': SAVE_CONFIRM_OK_MSG.format('\n\n'),1159 'title': SAVE_CONFIRM_OK_TITLE,1160 'type': gtk.MESSAGE_QUESTION,1161 'buttons': gtk.BUTTONS_YES_NO,1162 'c_1': gtk.RESPONSE_YES,1163 'f_1': SaveImage, 'p_1': (1164 self, self.save_device, self.save_image1165 )1166 },1167 True, False1168 )1169 )1170 self.window.add(self.outbox)...

Full Screen

Full Screen

processor.py

Source:processor.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3#4# ==============================================================================5# PAQUETE: canaima-semilla6# ARCHIVO: scripts/c-s.sh7# DESCRIPCIÓN: Script principal. Se encarga de invocar a los demás módulos y8# funciones según los parámetros proporcionados.9# USO: ./c-s.sh [MÓDULO] [PARÁMETROS] [...]10# COPYRIGHT:11# (C) 2010-2012 Luis Alejandro Martínez Faneyth <luis@huntingbears.com.ve>12# (C) 2012 Niv Sardi <xaiki@debian.org>13# LICENCIA: GPL-314# ==============================================================================15#16# This program is free software: you can redistribute it and/or modify17# it under the terms of the GNU General Public License as published by18# the Free Software Foundation, either version 3 of the License, or19# (at your option) any later version.20#21# This program is distributed in the hope that it will be useful,22# but WITHOUT ANY WARRANTY; without even the implied warranty of23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the24# COPYING file for more details.25#26# You should have received a copy of the GNU General Public License27# along with this program. If not, see <http://www.gnu.org/licenses/>.28#29# CODE IS POETRY30import gtk, sys, os, re, urllib2, fnmatch, threading, subprocess, random, gzip31import gobject, tempfile, Queue, hashlib, tempfile, subprocess, time, shutil32import aptsources.distinfo, ConfigParser33from canaimasemilla.constructor import ProgressWindow, UserMessage34from canaimasemilla.translator import *35from canaimasemilla.common import *36from canaimasemilla.config import *37def replace_all(text, dic):38 for i, j in dic.iteritems():39 text = text.replace(i, j)40 return text41def is_valid_url(url):42 regex = re.compile(43 r'^(http|ftp|file):///?'44 r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|'45 r'localhost|[a-zA-Z0-9-]*|'46 r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'47 r'(?::\d+)?'48 r'(?:/?|[/?]\S+)$',49 re.IGNORECASE50 )51 return regex.search(url)52class HeadRequest(urllib2.Request):53 def get_method(self):54 return "HEAD"55def KillProcess(reference, shell = [], python = [], terminal = False):56 for s in shell:57 k = ProcessGenerator(['/usr/bin/pkill', s], terminal = terminal)58 for p in python:59 p.kill()60 return True61def GetArch(terminal = False):62 p = ProcessGenerator(['/usr/bin/arch'], terminal = terminal)63 a = p.stdout.read().split('\n')[0]64 return a65def ParseProfileConfig(profile, get):66 conffile = PROFILEDIR+'/'+profile+'/profile.conf'67 f = open(conffile, 'r')68 ask = []69 give = []70 for line in f.readlines():71 for variable in get:72 if line.find(variable+'=') != -1:73 value = replace_all(line, {variable+'=':'', '"':'', '\n':''})74 ask.append(variable)75 give.append(value)76 f.close()77 return dict(zip(ask, give))78def copy2destination(items):79 try:80 for what, where in items:81 if what and os.path.exists(what):82 if os.path.isdir(f):83 if os.path.exists(where):84 return False85 shutil.copytree(os.path.realpath(f), where)86 else:87 if not os.path.exists(where):88 os.mkdir(where)89 shutil.copy2(os.path.realpath(f), where)90 except Exception, msg:91 return False92 return True93def GetFreeDisk():94 return float(subprocess.Popen(95 'echo "scale=1;$( df '+SHAREDIR+' | grep "/" | awk \'{print $4}\' )/(10^6)" | bc',96 shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,97 ).communicate()[0].split('\n')[0])98def GetFreeRam():99 return float(subprocess.Popen(100 'echo "scale=1;$( cat "/proc/meminfo" | grep "MemFree:" | awk \'{print $2}\' )/(10^3)" | bc',101 shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,102 ).communicate()[0].split('\n')[0])103def GetProcessors():104 return float(subprocess.Popen(105 'echo "scale=1;$( cat "/proc/cpuinfo" | grep -c "processor" )" | bc',106 shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,107 ).communicate()[0].split('\n')[0])108def GetWritableDrives():109 usb = subprocess.Popen(110 '/bin/sh '+BINDIR+'/'+CSBIN+' save -L',111 shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,112 ).communicate()[0].split('\n')113 opt = subprocess.Popen(114 '/bin/sh '+BINDIR+'/'+CSBIN+' save -l',115 shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,116 ).communicate()[0].split('\n')117 return opt+usb118def ProfileList(c, profiledir):119 profilelist = []120 items = next(os.walk(profiledir))[1]121 for i in items:122 profilelist.append(i)123 return profilelist, 0124def LocaleList(c, supported, current):125 localecount = 0126 localeactive = 0127 localelist = []128 with open(supported, 'r') as supportedlocales:129 for item in supportedlocales:130 localecode = item.split()131 localelist.append(localecode[0])132 if localecode[0].upper().replace('-','') == current.upper().replace('-',''):133 localeactive = localecount134 localecount += 1135 return localelist, localeactive136def CodenameList(c, dist, db):137 codenamelist = []138 codenameactive = 0139 udist = dist.get_active_text().title()140 d = aptsources.distinfo.DistInfo(udist, db)141 for template in d.templates:142 if not template.name in codenamelist:143 codenamelist.append(template.name)144 return codenamelist, codenameactive145def SectionList(c, dist):146 text = dist.get_active_text()147 exec "sectionlist = "+text+"_sections"148 return sectionlist149def CleanTempDir(tempdir):150 if not os.path.exists(tempdir):151 mktempdir = os.mkdir(tempdir)152 else:153 for path in os.listdir(tempdir):154 if os.path.isfile(tempdir+path) and fnmatch.fnmatch(tempdir+path, '*.gz'):155 os.unlink(tempdir+path)156 return True157class ThreadGenerator(threading.Thread):158 def __init__(self, reference, function, params,159 gtk = False, window = False, event = False):160 threading.Thread.__init__(self)161 self._gtk = gtk162 self._window = window163 self._function = function164 self._params = params165 self._event = event166 self.start()167 def run(self):168 if self._gtk:169 gtk.gdk.threads_enter()170 if self._event:171 self._event.wait()172 self._function(**self._params)173 if self._gtk:174 gtk.gdk.threads_leave()175 if self._window:176 self._window.hide()177def ProcessGenerator(command, terminal = False, bar = False):178 filename = '/tmp/cs-command-'+hashlib.sha1(179 str(random.getrandbits(random.getrandbits(10)))180 ).hexdigest()181 if isinstance(command, list):182 strcmd = ' '.join(command)183 elif isinstance(command, str):184 strcmd = command185 cmd = '{0} 1>{1} 2>&1'.format(strcmd, filename)186 try:187 os.mkfifo(filename)188 fifo = os.fdopen(os.open(filename, os.O_RDONLY | os.O_NONBLOCK))189 process = subprocess.Popen(190 cmd, shell = True, stdout = subprocess.PIPE,191 stderr = subprocess.STDOUT192 )193 if bar:194 timer = gobject.timeout_add(100, ProgressPulse, bar)195 while process.returncode == None:196 process.poll()197 try:198 line = fifo.readline().strip()199 if terminal:200 terminal.feed(line+'\r\n')201 except:202 continue203 finally:204 os.unlink(filename)205 if bar:206 gobject.source_remove(timer)207 return process208def TestIndexes(sourcestext, archlist, progressmessage, download,209 q_bar, q_msg, q_code, q_counter, event):210 bar = q_bar.get()211 message = q_msg.get()212 errorcounter = 0213 errorcode = ''214 sourceslist = []215 CleanTempDir(tempdir)216 if not download:217 timer = gobject.timeout_add(100, ProgressPulse, bar)218 for line in sourcestext.split('\n'):219 if line:220 parts = line.split(' ')221 parts = filter(None, parts)222 url = parts[1]223 branch = parts[2]224 sections = parts[3:]225 repo = [url, branch, sections]226 sourceslist.append(repo)227 for url, branch, sections in sourceslist:228 for section in sections:229 for arch in archlist:230 read = 0231 blocknum = 0232 contentheader = 0233 message.set_markup(progressmessage.format(section, branch, '\n', url, arch))234 requesturl = url+'/dists/'+branch+'/'+section+'/binary-'+arch+'/Packages.gz'235 time.sleep(1)236 if download:237 urlname = replace_all(url, forbidden_filename_chars)238 pkgcache = tempfile.NamedTemporaryFile(239 prefix = urlname+'-'+branch+'-',240 suffix = '-'+section+'_'+arch+'.gz',241 dir = tempdir, delete = False242 )243 try:244 if download:245 response = urllib2.urlopen(requesturl)246 else:247 response = urllib2.urlopen(HeadRequest(requesturl))248 except urllib2.HTTPError as e:249 errorcode = str(e.code)250 errorcounter += 1251 except urllib2.URLError as e:252 errorcode = str(e.reason)253 errorcounter += 1254 except IOError as e:255 errorcode = str(e.errno)+': '+str(e.strerror)256 errorcounter += 1257 except ValueError as e:258 errorcode = str(e)259 errorcounter += 1260 except TypeError as e:261 errorcode = str(e)262 errorcounter += 1263 except:264 errorcode = str(sys.exc_info()[0])265 errorcounter += 1266 else:267 headers = response.info()268 contentheader = int(headers["Content-Length"])269 if contentheader == 0:270 errorcode = ''271 errorcounter += 1272 if download:273 if errorcounter == 0:274 while True:275 block = response.read(bs)276 if not block:277 break278 pkgcache.write(block)279 pkgcache.flush()280 os.fsync(pkgcache.fileno())281 read += len(block)282 blocknum += 1283 percent = float(blocknum*bs)/contentheader284 if percent >= 1:285 percent = 1286 bar.set_fraction(percent)287 pkgcache.close()288 response.close()289 if read < contentheader:290 errorcode = ''291 errorcounter += 1292 if not download:293 gobject.source_remove(timer)294 q_bar.put(bar)295 q_msg.put(message)296 q_code.put(errorcode)297 q_counter.put(errorcounter)298 event.set()299def Toggle(r, do, dont = False, children = False,300 morechildren = False, alwaysoff = False):301 if children:302 widgetlist = do.get_children()303 if morechildren:304 for widget in widgetlist:305 morewidgets = widget.get_children()306 widgetlist = widgetlist + morewidgets307 else:308 widgetlist = do309 for widget in widgetlist:310 if widget != dont:311 if widget.get_sensitive() or alwaysoff:312 setting = False313 else:314 setting = True315 widget.set_sensitive(setting)316def ChangeCodename(r, c, codenamecombo, db):317 codenamelist, codenameactive = CodenameList(c, r, db)318 codenamecombo.get_model().clear()319 for item in codenamelist:320 codenamecombo.append_text(item)321 codenamecombo.set_active(codenameactive)322def ChangeRepo(r, c, repoentry):323 dist = r.get_active_text()324 exec "newrepotext = "+dist+"_repo"325 repoentry.set_text(newrepotext)326def ChangeSections(r, c, sections):327 checklist = SectionList(c, r)328 checkdefault = section_default329 children = sections.get_children()330 for child in children:331 sections.remove(child)332 for item in checklist:333 check = gtk.CheckButton(item)334 if item == checkdefault:335 check.set_active(True)336 check.set_sensitive(False)337 check.show()338 sections.pack_start(check, expand, fill, padding)339def AddExtraRepos(c, url_entry, branch_entry, sections_entry, arch_container,340 repolistframe):341 archs = []342 errorcounter = 0343 url = url_entry.get_text()344 branch = branch_entry.get_text()345 sections = sections_entry.get_text()346 repolist = repolistframe.get_text(*repolistframe.get_bounds())347 q_window = Queue.Queue()348 q_bar = Queue.Queue()349 q_msg = Queue.Queue()350 q_code = Queue.Queue()351 q_counter = Queue.Queue()352 event = threading.Event()353 for child in arch_container.get_children():354 if child.get_active():355 archs.append(child.get_label())356 sourcestext = 'deb '+url+' '+branch+' '+sections+'\n'357 if is_valid_url(url):358 if archs:359 if repolist.find(sourcestext) == -1:360 window_thread = ThreadGenerator(361 reference = c, function = ProgressWindow,362 params = {363 'text': PROFILE_OS_EXTRAREPOS_VALIDATE_MSG,364 'title': PROFILE_OS_EXTRAREPOS_VALIDATE_TITLE,365 'q_window': q_window,366 'q_bar': q_bar,367 'q_msg': q_msg368 }369 )370 index_thread = ThreadGenerator(371 reference = c, function = TestIndexes,372 params = {373 'sourcestext': sourcestext,374 'archlist': archs,375 'progressmessage': PROFILE_OS_EXTRAREPOS_VALIDATE_MSG,376 'download': False,377 'q_bar': q_bar,378 'q_msg': q_msg,379 'q_code': q_code,380 'q_counter': q_counter,381 'event': event382 }383 )384 write_thread = ThreadGenerator(385 reference = c, function = WriteExtraRepos,386 params = {387 'c': c,388 'url': url,389 'branch': branch,390 'sections': sections,391 'repolistframe': repolistframe,392 'repolist': repolist,393 'q_window': q_window,394 'q_code': q_code,395 'q_counter': q_counter396 },397 event = event398 )399 else:400 msg_thread = ThreadGenerator(401 reference = c, gtk = True, window = False,402 function = UserMessage, params = {403 'message': PROFILE_OS_EXTRAREPOS_VALIDATE_ARCH_ERROR_MSG.format('\n\n'),404 'title': PROFILE_OS_EXTRAREPOS_VALIDATE_ARCH_ERROR_TITLE,405 'type': gtk.MESSAGE_ERROR,406 'buttons': gtk.BUTTONS_CLOSE407 }408 )409 else:410 msg_thread = ThreadGenerator(411 reference = c, gtk = True, window = False,412 function = UserMessage, params = {413 'message': PROFILE_OS_EXTRAREPOS_VALIDATE_URL_ERROR_MSG.format(url, '\n\n'),414 'title': PROFILE_OS_EXTRAREPOS_VALIDATE_URL_ERROR_TITLE,415 'type': gtk.MESSAGE_ERROR,416 'buttons': gtk.BUTTONS_CLOSE417 }418 )419def WriteExtraRepos(c, url, branch, sections, repolistframe, repolist,420 q_window, q_code, q_counter):421 window = q_window.get()422 errorcode = q_code.get()423 errorcounter = q_counter.get()424 if errorcounter != 0:425 msg_thread = ThreadGenerator(426 reference = c, gtk = True, window = False,427 function = UserMessage, params = {428 'message': PROFILE_OS_EXTRAREPOS_VALIDATE_REPO_ERROR_MSG.format(errorcode, '\n\n', '\n\n'),429 'title': PROFILE_OS_EXTRAREPOS_VALIDATE_REPO_ERROR_TITLE,430 'type': gtk.MESSAGE_ERROR,431 'buttons': gtk.BUTTONS_CLOSE432 }433 )434 else:435 repolistframe.set_text(repolist+'deb '+url+' '+branch+' '+sections+'\n')436 window.destroy()437def AddPackages(c, url_entry, branch_entry, section_container, arch_container,438 extrareposframe, packages_entry, packageslistframe):439 archs = []440 sections = ''441 errorcounter = 0442 found = 0443 url = url_entry.get_text()444 branch = branch_entry.get_active_text()445 extrarepos = extrareposframe.get_text(*extrareposframe.get_bounds())446 packageslist = packageslistframe.get_text(*packageslistframe.get_bounds())447 packages = packages_entry.get_text()448 q_window = Queue.Queue()449 q_bar = Queue.Queue()450 q_msg = Queue.Queue()451 q_code = Queue.Queue()452 q_counter = Queue.Queue()453 event = threading.Event()454 for child in section_container.get_children():455 if child.get_active():456 sections = sections+child.get_label()+' '457 for child in arch_container.get_children():458 if child.get_active():459 archs.append(child.get_label())460 sourcestext = 'deb '+url+' '+branch+' '+sections+'\n'+extrarepos461 if archs:462 window_thread = ThreadGenerator(463 reference = c, function = ProgressWindow,464 params = {465 'text': PROFILE_OS_PACKAGES_VALIDATE_MSG,466 'title': PROFILE_OS_PACKAGES_VALIDATE_TITLE,467 'q_window': q_window,468 'q_bar': q_bar,469 'q_msg': q_msg470 }471 )472 index_thread = ThreadGenerator(473 reference = c, function = TestIndexes,474 params = {475 'sourcestext': sourcestext,476 'archlist': archs,477 'progressmessage': PROFILE_OS_PACKAGES_VALIDATE_MSG,478 'download': True,479 'q_bar': q_bar,480 'q_msg': q_msg,481 'q_code': q_code,482 'q_counter': q_counter,483 'event': event484 }485 )486 write_thread = ThreadGenerator(487 reference = c, function = WritePackages,488 params = {489 'c': c,490 'packages': packages,491 'packageslistframe': packageslistframe,492 'packageslist': packageslist,493 'q_window': q_window,494 'q_msg': q_msg,495 'q_bar': q_bar,496 'q_code': q_code,497 'q_counter': q_counter498 },499 event = event500 )501 else:502 msg_thread = ThreadGenerator(503 reference = c, gtk = True, window = False,504 function = UserMessage, params = {505 'message': PROFILE_OS_PACKAGES_VALIDATE_ARCH_ERROR_MSG.format('\n\n'),506 'title': PROFILE_OS_PACKAGES_VALIDATE_ARCH_ERROR_TITLE,507 'type': gtk.MESSAGE_ERROR,508 'buttons': gtk.BUTTONS_CLOSE509 }510 )511def WritePackages(c, packages, packageslistframe, packageslist,512 q_window, q_msg, q_bar, q_code, q_counter):513 window = q_window.get()514 bar = q_bar.get()515 message = q_msg.get()516 errorcode = q_code.get()517 errorcounter = q_counter.get()518 if errorcounter > 0:519 build_thread = ThreadGenerator(520 reference = c, gtk = True, window = False,521 function = UserMessage, params = {522 'message': PROFILE_OS_PACKAGES_VALIDATE_REPO_ERROR_MSG.format(errorcode, '\n\n', '\n\n'),523 'title': PROFILE_OS_PACKAGES_VALIDATE_REPO_ERROR_TITLE,524 'type': gtk.MESSAGE_ERROR,525 'buttons': gtk.BUTTONS_CLOSE526 }527 )528 else:529 timer = gobject.timeout_add(100, ProgressPulse, bar)530 for package in packages.split(' '):531 found = 0532 message.set_markup(PROFILE_OS_PACKAGES_VALIDATE_PKG_MSG.format(package, '\n'))533 for path in os.listdir(tempdir):534 if os.path.isfile(tempdir+path) and fnmatch.fnmatch(tempdir+path, '*.gz'):535 zipfile = gzip.open(tempdir+path)536 for line in zipfile.readlines():537 if line == 'Package: '+package+'\n':538 found += 1539 zipfile.close()540 if found > 0:541 packageslist = packageslistframe.get_text(*packageslistframe.get_bounds())542 packageslistframe.set_text(packageslist+' '+package)543 else:544 build_thread = ThreadGenerator(545 reference = c, gtk = True, window = False,546 function = UserMessage, params = {547 'message': PROFILE_OS_PACKAGES_VALIDATE_PKG_ERROR_MSG.format(package),548 'title': PROFILE_OS_PACKAGES_VALIDATE_PKG_ERROR_TITLE,549 'type': gtk.MESSAGE_ERROR,550 'buttons': gtk.BUTTONS_CLOSE551 }552 )553 gobject.source_remove(timer)554 window.destroy()555def BuildImage(c, profile_container, arch_container, media_container,556 window_container):557 profile = profile_container.get_active_text()558 arch_children = arch_container.get_children()559 media_children = media_container.get_children()560 q_window = Queue.Queue()561 q_bar = Queue.Queue()562 q_msg = Queue.Queue()563 q_terminal = Queue.Queue()564 q_code = Queue.Queue()565 q_counter = Queue.Queue()566 event = threading.Event()567 Toggle(568 r = c, dont = None, do = window_container, children = False,569 morechildren = False, alwaysoff = True570 )571 for child in arch_children:572 if child.get_active():573 if child.get_label() == BUILD_PROFILE_ARCH_AMD64:574 arch = 'amd64'575 else:576 arch = 'i386'577 for child in media_children:578 if child.get_active():579 if child.get_label() == BUILD_PROFILE_MEDIA_ISO:580 media = 'iso'581 elif child.get_label() == BUILD_PROFILE_MEDIA_IMG:582 media = 'usb'583 else:584 media = 'iso-hybrid'585 if os.path.exists(PROFILEDIR+'/'+profile+'/profile.conf'):586 get = ['META_REPO', 'META_CODENAME', 'META_REPOSECTIONS']587 config = ParseProfileConfig(profile, get)588 meta_repo = config['META_REPO']589 meta_reposections = config['META_REPOSECTIONS']590 meta_codename = config['META_CODENAME']591 mainrepo = 'deb '+meta_repo+' '+meta_codename+' '+meta_reposections+'\n'592 else:593 mainrepo = ''594 if os.path.exists(PROFILEDIR+'/'+profile+'/extra-repos.list'):595 f = open(PROFILEDIR+'/'+profile+'/extra-repos.list', 'r')596 extrarepos = f.read()597 else:598 extrarepos = ''599 sourcestext = mainrepo+extrarepos600 window_thread = ThreadGenerator(601 reference = c, function = ProgressWindow,602 params = {603 'text': BUILD_VALIDATE_SOURCES_MSG,604 'title': BUILD_WINDOW_TITLE,605 'term': True,606 'fcancel': KillProcess,607 'pcancel': (['lb', 'live-build', 'c-s'],),608 'q_window': q_window,609 'q_bar': q_bar,610 'q_msg': q_msg,611 'q_terminal': q_terminal612 }613 )614 index_thread = ThreadGenerator(615 reference = c, function = TestIndexes,616 params = {617 'sourcestext': sourcestext,618 'archlist': [arch,],619 'progressmessage': BUILD_VALIDATE_SOURCES_MSG,620 'download': False,621 'q_bar': q_bar,622 'q_msg': q_msg,623 'q_code': q_code,624 'q_counter': q_counter,625 'event': event626 }627 )628 build_thread = ThreadGenerator(629 reference = c, function = StartCS,630 params = {631 'c': c,632 'arch': arch,633 'media': media,634 'profile': profile,635 'q_bar': q_bar,636 'q_msg': q_msg,637 'q_terminal': q_terminal,638 'q_code': q_code,639 'q_counter': q_counter,640 'window': window_container641 },642 event = event643 )644def StartCS(c, arch, media, profile, q_bar, q_msg, q_terminal,645 q_code, q_counter, window):646 bar = q_bar.get()647 message = q_msg.get()648 terminal = q_terminal.get()649 errorcode = q_code.get()650 errorcounter = q_counter.get()651 if errorcounter != 0:652 build_thread = ThreadGenerator(653 reference = c, gtk = True, window = False,654 function = UserMessage, params = {655 'message': BUILD_VALIDATE_SOURCES_ERROR_MSG.format('\n\n'),656 'title': BUILD_VALIDATE_SOURCES_ERROR_TITLE,657 'type': gtk.MESSAGE_ERROR,658 'buttons': gtk.BUTTONS_CLOSE,659 'c_1': gtk.RESPONSE_CLOSE, 'f_1': Toggle,660 'p_1': (c, None, window, False, False, False)661 }662 )663 else:664 message.set_markup(BUILD_PROCESS_STATUS)665 process = ProcessGenerator(666 ['/bin/sh', BINDIR+'/'+CSBIN, 'build', '-a', arch, '-m', media, '-s', profile],667 terminal, bar668 )669 if process.returncode == 0:670 build_thread = ThreadGenerator(671 reference = c, gtk = True, window = False,672 function = UserMessage, params = {673 'message': BUILD_SUCCESSFUL_MSG,674 'title': BUILD_SUCCESSFUL_TITLE,675 'type': gtk.MESSAGE_ERROR,676 'buttons': gtk.BUTTONS_CLOSE,677 'c_1': gtk.RESPONSE_CLOSE, 'f_1': Toggle,678 'p_1': (c, None, window, False, False, False)679 }680 )681 else:682 build_thread = ThreadGenerator(683 reference = c, gtk = True, window = False,684 function = UserMessage, params = {685 'message': BUILD_FAILED_MSG,686 'title': BUILD_FAILED_TITLE,687 'type': gtk.MESSAGE_INFO,688 'buttons': gtk.BUTTONS_OK,689 'c_1': gtk.RESPONSE_OK, 'f_1': Toggle,690 'p_1': (c, None, window, False, False, False)691 }692 )693def ProgressPulse(bar):694 bar.pulse()695 return True696def CreateProfile(c, profilename, profilearch, authorname, authoremail,697 authorurl, oslocale, metadist, metacodename, metarepo,698 metareposections, osextrarepos, ospackages, imgpoolpackages,699 osincludes, imgincludes, oshooks, imghooks,700 imgsyslinuxsplash, imgdebianinstaller,701 imgdebianinstallerbanner, imgdebianinstallerpreseed,702 imgdebianinstallergtk703 ):704 _profilearch = ''705 for child in profilearch.get_children():706 if child.get_active():707 _profilearch = _profilearch+child.get_label()+' '708 _metareposections = ''709 for child in metareposections.get_children():710 if child.get_active():711 _metareposections = _metareposections+child.get_label()+' '712 _profilename = profilename.get_text()713 _authorname = authorname.get_text()714 _authoremail = authoremail.get_text()715 _authorurl = authorurl.get_text()716 _oslocale = oslocale.get_active_text()717 _metadist = metadist.get_active_text()718 _metacodename = metacodename.get_active_text()719 _metarepo = metarepo.get_text()720 _ospackages = ospackages.get_text(*ospackages.get_bounds())721 _osextrarepos = osextrarepos.get_text(*osextrarepos.get_bounds())722 _imgpoolpackages = imgpoolpackages.get_text(*imgpoolpackages.get_bounds())723 _osincludes = osincludes.get_text()724 _imgincludes = imgincludes.get_text()725 _oshooks = oshooks.get_text()726 _imghooks = imghooks.get_text()727 _imgsyslinuxsplash = imgsyslinuxsplash.get_text()728 _imgdebianinstaller = str(imgdebianinstaller.get_active()).lower()729 _imgdebianinstallerbanner = imgdebianinstallerbanner.get_text()730 _imgdebianinstallerpreseed = imgdebianinstallerpreseed.get_text()731 _imgdebianinstallergtk = imgdebianinstallergtk.get_text()732 profile_name = 'PROFILE_NAME="'+_profilename+'"\n'733 profile_arch = 'PROFILE_ARCH="'+_profilearch+'"\n'734 author_name = 'AUTHOR_NAME="'+_authorname+'"\n'735 author_email = 'AUTHOR_EMAIL="'+_authoremail+'"\n'736 author_url = 'AUTHOR_URL="'+_authorurl+'"\n'737 os_locale = 'OS_LOCALE="'+_oslocale+'"\n'738 meta_dist = 'META_DIST="'+_metadist+'"\n'739 meta_codename = 'META_CODENAME="'+_metacodename+'"\n'740 meta_repo = 'META_REPO="'+_metarepo+'"\n'741 meta_reposections = 'META_REPOSECTIONS="'+_metareposections+'"\n'742 os_packages = 'OS_PACKAGES="'+_ospackages+'"\n'743 os_extrarepos = 'OS_EXTRAREPOS="profile"\n'744 img_pool_packages = 'IMG_POOL_PACKAGES="'+_imgpoolpackages+'"\n'745 os_includes = 'OS_INCLUDES="profile"\n'746 img_includes = 'IMG_INCLUDES="profile"\n'747 os_hooks = 'OS_HOOKS="profile"\n'748 img_hooks = 'IMG_HOOKS="profile"\n'749 img_syslinux_splash = 'IMG_SYSLINUX_SPLASH="profile"\n'750 img_debian_installer = 'IMG_DEBIAN_INSTALLER="'+_imgdebianinstaller+'"\n'751 img_debian_installer_banner = 'IMG_DEBIAN_INSTALLER_BANNER="profile"\n'752 img_debian_installer_preseed = 'IMG_DEBIAN_INSTALLER_PRESEED="profile"\n'753 img_debian_installer_gtk = 'IMG_DEBIAN_INSTALLER_GTK="profile"\n'754 content = profile_name+profile_arch+author_name+author_email+author_url+os_locale+meta_dist+meta_codename+meta_repo+meta_reposections+os_extrarepos+os_packages+img_pool_packages+os_includes+img_includes+os_hooks+img_hooks+img_syslinux_splash+img_debian_installer+img_debian_installer_banner+img_debian_installer_preseed+img_debian_installer_gtk755 if not os.path.exists(PROFILEDIR+'/'+_profilename):756 os.mkdir(PROFILEDIR+'/'+_profilename)757 f = open(PROFILEDIR+'/'+_profilename+'/profile.conf', 'wb')758 f.write(content)759 f.close()760 761 if _osextrarepos:762 e = open(PROFILEDIR+'/'+_profilename+'/extra-repos.list', 'wb')763 e.write(_osextrarepos)764 e.close()765 copythis = [766 [ _osincludes, PROFILEDIR+'/'+_profilename+'/OS_INCLUDES'],767 [ _oshooks, PROFILEDIR+'/'+_profilename+'/OS_HOOKS'],768 [ _imgincludes, PROFILEDIR+'/'+_profilename+'/IMG_INCLUDES'],769 [ _imghooks, PROFILEDIR+'/'+_profilename+'/IMG_HOOKS'],770 [ _imgsyslinuxsplash, PROFILEDIR+'/'+_profilename],771 [ _imgdebianinstallerbanner, PROFILEDIR+'/'+_profilename+'/DEBIAN_INSTALLER'],772 [ _imgdebianinstallerpreseed, PROFILEDIR+'/'+_profilename+'/DEBIAN_INSTALLER'],773 [ _imgdebianinstallergtk, PROFILEDIR+'/'+_profilename+'/DEBIAN_INSTALLER'],774 ]775 if copy2destination(copythis):776 success_thread = ThreadGenerator(777 reference = c, gtk = True, window = False,778 function = UserMessage, params = {779 'message': PROFILE_CREATING_SUCCESS_MSG,780 'title': PROFILE_CREATING_SUCCESS_TITLE,781 'type': gtk.MESSAGE_INFO,782 'buttons': gtk.BUTTONS_OK783 }784 )785 else:786 error_thread = ThreadGenerator(787 reference = c, gtk = True, window = False,788 function = UserMessage, params = {789 'message': PROFILE_CREATING_UNKNOWN_ERROR_MSG,790 'title': PROFILE_CREATING_UNKNOWN_ERROR_TITLE,791 'type': gtk.MESSAGE_ERROR,792 'buttons': gtk.BUTTONS_OK793 }794 )795 else:796 error_thread = ThreadGenerator(797 reference = c, gtk = True, window = False,798 function = UserMessage, params = {799 'message': PROFILE_CREATING_EXISTS_ERROR_MSG,800 'title': PROFILE_CREATING_EXISTS_ERROR_TITLE,801 'type': gtk.MESSAGE_ERROR,802 'buttons': gtk.BUTTONS_OK803 }804 )805def TestImage(c, image_entry, memory_entry, processors_entry, start_container):806 image = image_entry.get_text()807 memory = memory_entry.get_value()808 processors = processors_entry.get_value()809 for child in start_container.get_children():810 if child.get_active():811 if child.get_label() == TEST_START_CD_LABEL:812 start = '-c'813 else:814 start = '-d'815 build_thread = ThreadGenerator(816 reference = c, gtk = False, window = False,817 function = ProcessGenerator, params = {818 'command': [819 '/bin/sh', BINDIR+'/'+CSBIN, 'test', '-i', image,820 '-m', str(int(memory)), '-p', str(int(processors)), start, '-n',821 '-s', '10'822 ]823 }824 )825def SaveImage(c, device_combo, image_entry, window_container):826 device = device_combo.get_active_text()827 image = image_entry.get_text()828 q_window = Queue.Queue()829 q_bar = Queue.Queue()830 q_msg = Queue.Queue()831 q_terminal = Queue.Queue()832 window_thread = ThreadGenerator(833 reference = c, function = ProgressWindow,834 params = {835 'text': SAVE_WRITE_MSG,836 'title': SAVE_WRITE_TITLE,837 'term': True,838 'fcancel': KillProcess,839 'pcancel': (['wodim', 'c-s', 'dd'],),840 'q_window': q_window,841 'q_bar': q_bar,842 'q_msg': q_msg,843 'q_terminal': q_terminal844 }845 )846 window_thread = ThreadGenerator(847 reference = c, function = SaveImage2,848 params = {849 'c': c,850 'image': image,851 'device': device,852 'q_bar': q_bar,853 'q_msg': q_msg,854 'q_terminal': q_terminal,855 'window': window_container856 }857 )858def SaveImage2(c, image, device, q_bar, q_msg, q_terminal, window):859 bar = q_bar.get()860 message = q_msg.get()861 terminal = q_terminal.get()862 process = ProcessGenerator(863 ['/bin/sh', BINDIR+'/'+CSBIN, 'save', '-i', image, '-d', device, '-q'],864 terminal, bar865 )866 if process.returncode == 0:867 build_thread = ThreadGenerator(868 reference = c, gtk = True, window = False,869 function = UserMessage, params = {870 'message': SAVE_SUCCESSFUL_MSG,871 'title': SAVE_SUCCESSFUL_TITLE,872 'type': gtk.MESSAGE_ERROR,873 'buttons': gtk.BUTTONS_CLOSE,874 'c_1': gtk.RESPONSE_CLOSE, 'f_1': Toggle,875 'p_1': (c, window)876 }877 )878 else:879 build_thread = ThreadGenerator(880 reference = c, gtk = True, window = False,881 function = UserMessage, params = {882 'message': SAVE_FAILED_MSG,883 'title': SAVE_FAILED_TITLE,884 'type': gtk.MESSAGE_INFO,885 'buttons': gtk.BUTTONS_OK,886 'c_1': gtk.RESPONSE_OK, 'f_1': Toggle,887 'p_1': (c, window)888 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful