rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
sys.exit(1)
raise UnsupportedException
def copy_volume(self, image_path, volume_path, excludes, generate_fstab, fstab_path): mount_point, loop_dev = self.mount_image(image_path)
while 1:
buf = in_file.read(IMAGE_IO_CHUNK) while buf: sha_image.update(buf)
def check_image(self, image_file, path): print 'Checking image' if not os.path.exists(path): os.makedirs(path) image_size = os.path.getsize(image_file) if self.debug: print 'Image Size:', image_size, 'bytes' in_file = open(image_file, 'rb') sha_image = sha() while 1: buf = in_file.read(IMAGE_IO_CHUNK) if not buf: break...
if not buf: break sha_image.update(buf)
def check_image(self, image_file, path): print 'Checking image' if not os.path.exists(path): os.makedirs(path) image_size = os.path.getsize(image_file) if self.debug: print 'Image Size:', image_size, 'bytes' in_file = open(image_file, 'rb') sha_image = sha() while 1: buf = in_file.read(IMAGE_IO_CHUNK) if not buf: break...
output = Popen(rsync_cmd, stdout=PIPE, stderr=PIPE).communicate()
pipe = Popen(rsync_cmd, stdout=PIPE, stderr=PIPE) output = pipe.communicate()
def copy_to_image(self, mount_point, volume_path, excludes):
if output[1]: raise CopyError
if pipe.returncode: if pipe.returncode in (23, 24): print "Warning: rsync reports files partially copied:" print output else: print "Error: rsync failed with return code %d" % pipe.returncode raise CopyError
def copy_to_image(self, mount_point, volume_path, excludes):
self.ec2_url = None self.s3_url = None
self.url = None
def __init__( self, short_opts=None, long_opts=None, is_s3=False, compat=False, ): self.ec2_user_access_key = None self.ec2_user_secret_key = None self.ec2_url = None self.s3_url = None self.config_file_path = None self.is_s3 = is_s3 if compat: self.secret_key_opt = 'S' self.access_key_opt = 'A' else: self.secret_key_o...
self.ec2_url = value
self.url = value
def __init__( self, short_opts=None, long_opts=None, is_s3=False, compat=False, ): self.ec2_user_access_key = None self.ec2_user_secret_key = None self.ec2_url = None self.s3_url = None self.config_file_path = None self.is_s3 = is_s3 if compat: self.secret_key_opt = 'S' self.access_key_opt = 'A' else: self.secret_key_o...
if not self.ec2_url: self.ec2_url = self.environ['EC2_URL'] if not self.ec2_url: self.ec2_url = \
if not self.url: self.url = self.environ['EC2_URL'] if not self.url: self.url = \
def make_connection(self): if not self.ec2_user_access_key: self.ec2_user_access_key = self.environ['EC2_ACCESS_KEY'] if not self.ec2_user_access_key: print 'EC2_ACCESS_KEY environment variable must be set.' raise ConnectionFailed
% self.ec2_url
% self.url
def make_connection(self): if not self.ec2_user_access_key: self.ec2_user_access_key = self.environ['EC2_ACCESS_KEY'] if not self.ec2_user_access_key: print 'EC2_ACCESS_KEY environment variable must be set.' raise ConnectionFailed
if not self.ec2_url: self.ec2_url = self.environ['S3_URL'] if not self.ec2_url: self.ec2_url = \
if not self.url: self.url = self.environ['S3_URL'] if not self.url: self.url = \
def make_connection(self): if not self.ec2_user_access_key: self.ec2_user_access_key = self.environ['EC2_ACCESS_KEY'] if not self.ec2_user_access_key: print 'EC2_ACCESS_KEY environment variable must be set.' raise ConnectionFailed
if self.ec2_url.find('https://') >= 0: self.ec2_url = self.ec2_url.replace('https://', '')
rslt = urlparse.urlparse(self.url) if rslt.scheme == 'https':
def make_connection(self): if not self.ec2_user_access_key: self.ec2_user_access_key = self.environ['EC2_ACCESS_KEY'] if not self.ec2_user_access_key: print 'EC2_ACCESS_KEY environment variable must be set.' raise ConnectionFailed
self.ec2_url = self.ec2_url.replace('http://', '')
def make_connection(self): if not self.ec2_user_access_key: self.ec2_user_access_key = self.environ['EC2_ACCESS_KEY'] if not self.ec2_user_access_key: print 'EC2_ACCESS_KEY environment variable must be set.' raise ConnectionFailed
self.host = self.ec2_url url_parts = self.ec2_url.split(':') if len(url_parts) > 1: self.host = url_parts[0] path_parts = url_parts[1].split('/', 1) if len(path_parts) > 1: self.port = int(path_parts[0]) self.service_path = self.service_path + path_parts[1] else: self.port = int(url_parts[1])
self.host = rslt.netloc l = self.host.split(':') if len(l) > 1: self.host = l[0] self.port = int(l[1]) if rslt.path: self.service_path = rslt.path
def make_connection(self): if not self.ec2_user_access_key: self.ec2_user_access_key = self.environ['EC2_ACCESS_KEY'] if not self.ec2_user_access_key: print 'EC2_ACCESS_KEY environment variable must be set.' raise ConnectionFailed
block_dev_type = BlockDeviceType()
block_dev_type = EBSBlockDeviceType()
def parse_block_device_args(self, block_device_maps_args): block_device_map = BlockDeviceMapping() for block_device_map_arg in block_device_maps_args: parts = block_device_map_arg.split('=') if len(parts) > 1: device_name = parts[0] block_dev_type = BlockDeviceType() value_parts = parts[1].split(':') if value_parts[0]....
tar_cmd = ['tar', 'c', '-S']
tar_cmd = ['tar', 'ch', '-S']
def tarzip_image( self, prefix, file, path, ): Util().check_prerequisite_command('tar')
os.path.join(os.getenv('HOME'), ".eucarc")
user_eucarc = os.path.join(os.getenv('HOME'), ".eucarc")
def setup_environ(self):
version_string = """ Version: 1.2 (BSD)""" def version(self): return self.version_string
def make_essential_devs(self, image_path):
file_path = filename.replace(relative_filename, '')
file_path=os.path.dirname(filename)
def get_file_path(self, filename):
print "Closed"
print "Mythfrontend connection closed" self.owner.socket_disconnect()
def handle_close(self): print "Closed" self.close()
To re-try, hold down the power button on your wiimote to disconnect it.
def handle_read(self): try: self.data = self.data + self.recv(8192) except: print """
self.close()
self.handle_close()
def handle_read(self): try: self.data = self.data + self.recv(8192) except: print """
self.ms.cmd('play speed normal')
if not (state['buttons'] & cwiid.BTN_B): self.ms.cmd('play speed normal')
def wmcb(self, messages): state = self.state for message in messages: if message[0] == cwiid.MESG_BTN: state["buttons"] = message[1] #elif message[0] == cwiid.MESG_STATUS: # print "\nStatus: ", message[1] elif message[0] == cwiid.MESG_ERROR: if message[1] == cwiid.ERROR_DISCONNECT: self.wm = None if self.ms is not None...
cmd += abs(speed)*"key right\n"
cmd += (speed / 5) * "key up\n" cmd += (speed % 5) * "key right\n"
def wmcb(self, messages): state = self.state for message in messages: if message[0] == cwiid.MESG_BTN: state["buttons"] = message[1] #elif message[0] == cwiid.MESG_STATUS: # print "\nStatus: ", message[1] elif message[0] == cwiid.MESG_ERROR: if message[1] == cwiid.ERROR_DISCONNECT: self.wm = None if self.ms is not None...
cmd += abs(speed)*"key left\n"
cmd += (-speed / 5) * "key down\n" cmd += (-speed % 5) * "key left\n"
def wmcb(self, messages): state = self.state for message in messages: if message[0] == cwiid.MESG_BTN: state["buttons"] = message[1] #elif message[0] == cwiid.MESG_STATUS: # print "\nStatus: ", message[1] elif message[0] == cwiid.MESG_ERROR: if message[1] == cwiid.ERROR_DISCONNECT: self.wm = None if self.ms is not None...
yield (path, kind, action, p_path, p_rev)
yield (to_unicode(path), kind, action, to_unicode(p_path), p_rev)
def get_changes(self): paths_seen = set() for parent in self.props.get('parent', [None]): for mode1,mode2,obj1,obj2,action,path1,path2 in \ self.repos.git.diff_tree(parent, self.rev, find_renames=True): path = path2 or path1 p_path, p_rev = path1, parent
elif GitCore.is_sha(rc): self.__rev_cache = None return self.verifyrev(rev)
def verifyrev(self, rev): "verify/lookup given revision object and return a sha id or None if lookup failed" rev = str(rev)
self.log.info("enabled CachedRepository for '%s'" % dir)
self.log.debug("enabled CachedRepository for '%s'" % dir)
def rlookup_uid(_): return None
self.log.info("disabled CachedRepository for '%s'" % dir)
self.log.debug("disabled CachedRepository for '%s'" % dir)
def rlookup_uid(_): return None
user_,time_ = props[name] _str = user_ + " / " + time_.strftime('%Y-%m-%dT%H:%M:%SZ%z')
user_, time_ = props[name] _str = "%s (%s)" % (Chrome(self.env).format_author(context.req, user_), format_datetime(time_, tzinfo=context.req.tz))
def sha_link(sha): return self._format_sha_link(context, 'sha', sha, sha)
meta, fname = l.split('\t')
meta, fname = l.split('\t', 1)
def split_ls_tree_line(l): "split according to '<mode> <type> <sha> <size>\t<fname>'"
['pyiwconfig'])
[])
def __init__(self): self.XML_LOG_VERSION = 'V2' # For ease of comparison in database, we use ##.##.## format for version: self.SOFTWARE_VERSION = '00.00.00' # strings which will be used in the configuration file self.GENERAL = 'General' self.OBM_LOGS_DIR_NAME = 'OpenBmap logs directory name' self.OBM_PROCESSED_LOGS_DIR...
pluginsNames = eval(self.get_config_value(self.GENERAL, self.LIST_OF_ACTIVE_PLUGINS))
pluginsNames = eval(str(self.get_config_value(self.GENERAL, self.LIST_OF_ACTIVE_PLUGINS)))
def load_active_plugins(self): """Tries loading active plugins. Returns a list of successfully loaded pluging.""" result = [] pluginsNames = eval(self.get_config_value(self.GENERAL, self.LIST_OF_ACTIVE_PLUGINS))
def is_logging(self):
def is_logging(self, synchronised=True):
def is_logging(self): """Returns True if logging plugin(s) is(are) scheduled or working. False otherwise.""" self._loggerLock.acquire() logging.debug('OBM logger locked by is_logging().') result = (self._loggingThread != None) logging.debug('Is the GSM logger running? %s' % (result and 'Yes' or 'No') ) if not result: #...
self._loggerLock.acquire() logging.debug('OBM logger locked by is_logging().')
if synchronised: self._loggerLock.acquire() logging.debug('OBM logger locked by is_logging().') else: logging.debug('OBM logger unsynchronised call to is_logging().')
def is_logging(self): """Returns True if logging plugin(s) is(are) scheduled or working. False otherwise.""" self._loggerLock.acquire() logging.debug('OBM logger locked by is_logging().') result = (self._loggingThread != None) logging.debug('Is the GSM logger running? %s' % (result and 'Yes' or 'No') ) if not result: #...
self._loggerLock.release() logging.debug('OBM logger lock released by is_logging().')
if synchronised: self._loggerLock.release() logging.debug('OBM logger lock released by is_logging().')
def is_logging(self): """Returns True if logging plugin(s) is(are) scheduled or working. False otherwise.""" self._loggerLock.acquire() logging.debug('OBM logger locked by is_logging().') result = (self._loggingThread != None) logging.debug('Is the GSM logger running? %s' % (result and 'Yes' or 'No') ) if not result: #...
obj = dbus.SystemBus().get_object('org.freesmartphone.ogsmd', '/org/freesmartphone/GSM/Device') data = dbus.Interface(obj, 'org.freesmartphone.GSM.Device').GetInfo()
try: obj = dbus.SystemBus().get_object('org.freesmartphone.ogsmd', '/org/freesmartphone/GSM/Device') data = dbus.Interface(obj, 'org.freesmartphone.Info').GetInfo() except Exception, e1: logging.error(e1) logging.info("Try the old GetInfo API") try: data = dbus.Interface(obj, 'org.freesmartphone.GSM.Device').GetInfo(...
def get_device_info(self): """If available, returns the manufacturer, model and revision.""" #TODO call the dBus interface only if instance attributes are not set. obj = dbus.SystemBus().get_object('org.freesmartphone.ogsmd', '/org/freesmartphone/GSM/Device') data = dbus.Interface(obj, 'org.freesmartphone.GSM.Device')....
line = line.replace("|","\n")
def GetSubtitleList(self, path): outputList = [] f = self.convertFile(path) #f = open(path, 'r') state = SubtitlesLoader.LOOK_FOR_ID for line in f: line = line.rstrip() line = line.decode("utf8")
mygtk.show_error(_(u"You need to install the gstreamer soundtouch elements for "
print (_(u"You need to install the gstreamer soundtouch elements for "
def __init__(self):
"README if you need more information.")).run()
"README if you need more information."))
def __init__(self):
"lastOpenFile" : None
"lastOpenFile" : ""
def __new__(cls): if cls._instance is None: cls._instance = object.__new__(cls) cls._instance.init() return cls._instance
self.properties.update( dict(self.configParser.items("files")) )
def init(self): self.properties = {} self.properties["version"] = APP_VERSION self.properties["app_name"] = APP_NAME self.properties["gettext_package"] = "perroquet" self.properties["executable"] = os.path.dirname(sys.executable) self.properties["script"] = sys.path[0] self.properties["config_dir"] = os.path.join( os.p...
repository.init_from_path(os.path.join(self.config.get("local_repo_root_dir"),repoPath))
repository.init_from_path(os.path.join(config.get("local_repo_root_dir"),repoPath))
def _get_distant_exercise_repository_list(self): """Build and return a list of distant and offline repositories. There is one repository initialized for each url found in the config files. If the url is reachable, a distant repository is initialized, else an offline repository is created. """ #Get the list of files con...
repoPathList = os.listdir(self.config.get("local_repo_root_dir"))
repoPathList = os.listdir(config.get("local_repo_root_dir"))
def _get_orphan_exercise_repository_list(self,repositoryListIn): repoPathList = os.listdir(self.config.get("local_repo_root_dir")) repoUsedPath = [] repositoryList = [] for repo in repositoryListIn: repoUsedPath.append(repo.get_local_path())
path = os.path.join(self.config.get("local_repo_root_dir"), repoPath)
path = os.path.join(config.get("local_repo_root_dir"), repoPath)
def _get_orphan_exercise_repository_list(self,repositoryListIn): repoPathList = os.listdir(self.config.get("local_repo_root_dir")) repoUsedPath = [] repositoryList = [] for repo in repositoryListIn: repoUsedPath.append(repo.get_local_path())
localRepoPath = os.path.join(self.config.get("local_repo_root_dir"),"local")
localRepoPath = os.path.join(config.get("local_repo_root_dir"),"local")
def import_package(self, import_path):
lang = os.path.basename(os.path.dirname(mo))
lang = os.path.basename(os.path.dirname(os.path.dirname(mo)))
def _find_mo_files (self): data_files = []
if self.workValidityList[self.activeWordIndex] < 0:
if not startWith(self.wordList[self.activeWordIndex], self.workList[self.activeWordIndex]):
def WorkChange(self): """Update the validity of the current word""" self.ComputeValidity(self.activeWordIndex)
print "set_lock_correction " print new_password
def set_lock_correction(self, state, new_password = None): self.lock_correction = state print "set_lock_correction " print new_password if new_password is not None: salt = "" pop = string.hexdigits while len(salt) < 6: salt += random.choice(pop)
path = modele.get(iter, 0)[0] self.controller.notify_load_path(path)
if iter is not None: path = modele.get(iter, 0)[0] self.controller.notify_load_path(path)
def on_lastopenfilesTreeView_cursor_changed(self, widget, data=None): gtkTree = self.builder.get_object("lastopenfilesTreeView") gtkSelection = gtkTree.get_selection() (modele, iter) = gtkSelection.get_selected() path = modele.get(iter, 0)[0] self.controller.notify_load_path(path)
"Load the config file and add it to configParser"
def _loadConfigFiles(self): "Load the config file and add it to configParser" self._localConfFilHref = os.path.join( self.Get("localConfigDir"), "config") self._globalConfFilHref = os.path.join( self.Get("globalConfigDir"), "config")
if len( configParser.read(self._globalConfFilHref)) == 0: print "Error : gui file "+self._globalConfFilHref+" not found"
if os.path.isfile(self._globalConfFilHref): configParser.read(self._globalConfFilHref) elif os.path.isfile(os.path.join(self.Get("script"), '/data/config')): configParser.read("../data/config") else: print "Error : global conf file 'config' not found"
def _loadConfigFiles(self): "Load the config file and add it to configParser" self._localConfFilHref = os.path.join( self.Get("localConfigDir"), "config") self._globalConfFilHref = os.path.join( self.Get("globalConfigDir"), "config")
"lastOpenFile" = None
"lastOpenFile" : None
def __new__(cls): if cls._instance is None: cls._instance = object.__new__(cls) cls._instance.init() return cls._instance
def _load_Files(self): href = os.path.join( self.Get("config_dir", "config")
self.configParser = self._load_Files("files") def _load_Files(self, section): "Load the config file and add it to configParser" href = os.path.join( self.Get("config_dir"), "config")
def _load_Files(self): href = os.path.join( self.Get("config_dir", "config") self.configParser = ConfigParser.ConfigParser() if len( self.configParser.read(href)) == 0: print "No conf file find" for (key, values) in defaultConf.items("): if not key in self.configParser.options(): self.configParser.set("default", key, ...
self.configParser = ConfigParser.ConfigParser() if len( self.configParser.read(href)) == 0:
configParser = ConfigParser.ConfigParser() if len( configParser.read(href)) == 0:
def _load_Files(self): href = os.path.join( self.Get("config_dir", "config") self.configParser = ConfigParser.ConfigParser() if len( self.configParser.read(href)) == 0: print "No conf file find" for (key, values) in defaultConf.items("): if not key in self.configParser.options(): self.configParser.set("default", key, ...
for (key, values) in defaultConf.items("): if not key in self.configParser.options(): self.configParser.set("default", key, value)
if not configParser.has_section(section): configParser.add_section(section) for (key, value) in self.__class__.defaultConf.items(): if not key in configParser.options(section): configParser.set(section, key, value) return configParser
def _load_Files(self): href = os.path.join( self.Get("config_dir", "config") self.configParser = ConfigParser.ConfigParser() if len( self.configParser.read(href)) == 0: print "No conf file find" for (key, values) in defaultConf.items("): if not key in self.configParser.options(): self.configParser.set("default", key, ...
self.builder.get_object("vbox2").show()
self.builder.get_object("lateralPanel").show()
def set_visible_lateral_panel(self, state): if state: self.builder.get_object("vbox2").show() else: self.builder.get_object("vbox2").hide()
self.builder.get_object("vbox2").hide()
self.builder.get_object("lateralPanel").hide()
def set_visible_lateral_panel(self, state): if state: self.builder.get_object("vbox2").show() else: self.builder.get_object("vbox2").hide()
print "plip"
def on_checkmenuitem_correction_toggled(self, widget, data=None): print "plip" toolbutton_show_correction = self.builder.get_object("toolbutton_show_correction") self.controller.notify_toogle_correction(toolbutton_show_correction.props.active)
print "plop"
def on_toolbutton_show_correction_toggled(self, widget, data=None): print "plop" toolbutton_show_correction = self.builder.get_object("toolbutton_show_correction") self.controller.notify_toogle_correction(toolbutton_show_correction.props.active)
self.builder.get_object("toolbuttonPlay").shide()
self.builder.get_object("toolbuttonPlay").hide()
def set_visible_play(self, state): if state: self.builder.get_object("toolbuttonPlay").show() else: self.builder.get_object("toolbuttonPlay").shide()
self.builder.get_object("toolbuttonPause").shide()
self.builder.get_object("toolbuttonPause").hide()
def set_visible_pause(self, state): if state: self.builder.get_object("toolbuttonPause").show() else: self.builder.get_object("toolbuttonPause").shide()
self.gui.logger.debug("visible="+visible+" , correction_visible="+self.correction_visible)
self.gui.logger.debug("visible="+str(visible)+" , correction_visible="+str(self.correction_visible))
def notify_toogle_correction(self,visible): self.gui.logger.debug("notify_toogle_correction") self.gui.logger.debug("visible="+visible+" , correction_visible="+self.correction_visible) if visible != self.correction_visible: self.toggle_correction()
('share/perroquet/', ['data/languages_aliases.ini']),
def _find_mo_files (self): data_files = []
if self.outputSavePath == "": self.outputSavePath = self.gui.AskSavePath() if self.outputSavePath == "":
if saveAs or self.outputSavePath == "": outputSavePath = self.gui.AskSavePath() if outputSavePath == None:
def Save(self, saveAs = False):
elif saveAs: tempPath = self.gui.AskSavePath() if tempPath == "": return self.outputSavePath = tempPath
self.outputSavePath = outputSavePath
def Save(self, saveAs = False):
('etc/perroquet/', ['data/config.ini']), ('etc/perroquet/', ['data/languages_aliases.ini']), ('etc/perroquet/', ['data/sources.conf']),
('/etc/perroquet/', ['data/config.ini']), ('/etc/perroquet/', ['data/languages_aliases.ini']), ('/etc/perroquet/', ['data/sources.conf']),
def _find_mo_files (self): data_files = []
iter = self.pathListStore.insert_after(self.iterPath, [self.pathListStore.get_value(self.iterPath,0), self.pathListStore.get_value(self.iterPath,1), self.pathListStore.get_value(self.iterPath,2), self.pathListStore.get_value(self.iterPath,3) ])
if self.iterPath is None: self.iterPath = self.pathListStore.get_iter_first() while self.pathListStore.iter_next(self.iterPath) is not None: self.iterPath = self.pathListStore.iter_next(self.iterPath) iter = self.pathListStore.insert_after(self.iterPath, [self.pathListStore.get_value(self.iterPath, 0), self.pathListSt...
def on_button_add_path_clicked(self,widget,data=None): self.__store_path_changes() iter = self.pathListStore.insert_after(self.iterPath, [self.pathListStore.get_value(self.iterPath,0), self.pathListStore.get_value(self.iterPath,1), self.pathListStore.get_value(self.iterPath,2), self.pathListStore.get_value(self.iterPat...
if self.core.GetCanSave(): self.core.Save()
self.core.Save()
def on_MainWindow_delete_event(self,widget,data=None): if not self.config.Get("autosave"): if not self.core.GetCanSave(): gtk.main_quit() return False
def test_affd():
def testAffd():
def test_affd(): pass
def test_bddr():
def testBddr():
def test_bddr(): pass
["test_affd", "test_bddr"])
["testAffd", "testBddr"])
def test_ee(): pass
gtkTree.append_column(treeViewColumn)
treeViewColumn.pack_start(cell, False) treeViewColumn.add_attribute(cell, 'markup', 0) treeViewColumn.set_expand(False) gtkTree.append_column(treeViewColumn)
def _updateLastOpenFilesTab(self): print "updateLastOpenFilesTab" gtkTree = self.builder.get_object("lastopenfilesTreeView") if not gtkTree.get_columns() == []: raise Exception treeViewColumn = gtk.TreeViewColumn(_("Path")) gtkTree.append_column(treeViewColumn) print gtkTree.get_columns() treeStore = gtk.TreeStore(st...
self.connect("confirm-overwrite", self.__cb_confirm_overwrite) def __cb_confirm_overwrite(self, widget, data = None): "Handles confirm-overwrite signals" try: FileReplace(self, io.file_normpath(self.get_uri())).run() except: return gtk.FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN else: return gtk.FILE_CHOOSER_CONFIRMATI...
def __init__(self, parent): FileSelector.__init__( self, parent, _('Select File to Save to'), gtk.FILE_CHOOSER_ACTION_SAVE, gtk.STOCK_SAVE )
self.activate_video_area(True)
def on_sync_message(self, bus, message): if message.structure is None: return message_name = message.structure.get_name() if message_name == "prepare-xwindow-id": gtk.gdk.threads_enter() gtk.gdk.display_get_default().sync() imagesink = message.src imagesink.set_property("force-aspect-ratio", True) imagesink.set_xwindow...
def activate_video_callback(self, activateVideo): self.activateVideo = activateVideo
def activate_video_callback(self, activate_video): self.activate_video_area = activate_video
def activate_video_callback(self, activateVideo): self.activateVideo = activateVideo
def _updateProperties(self):
def UpdateProperties(self):
def _updateProperties(self): self.exercise.Initialize() self._Reload(True) self.SetCanSave(True) self._ActivateSequence() self.GotoSequenceBegin(True) self.Play()
elif os.path.isfile(os.path.join(self.Get("script"), '/data/config')): configParser.read("../data/config")
elif os.path.isfile(os.path.join(self.Get("script"), 'data/config')): configParser.read(os.path.join(self.Get("script"), 'data/config'))
def _loadConfigFiles(self): """Load the config files and add it to configParser All modifiable options must be on data/config""" self._localConfFilHref = os.path.join( self.Get("localConfigDir"), "config") self._globalConfFilHref = os.path.join( self.Get("globalConfigDir"), "config")
print "Error : global conf file 'config' not found"
print "Error : global conf file 'config' not found at "+ os.path.join(self.Get("script"), 'data/config')
def _loadConfigFiles(self): """Load the config files and add it to configParser All modifiable options must be on data/config""" self._localConfFilHref = os.path.join( self.Get("localConfigDir"), "config") self._globalConfFilHref = os.path.join( self.Get("globalConfigDir"), "config")
m = re.search('([0-9]{2}):([0-9]{2}):([0-9]{2}),([0-9]{3}) --> ([0-9]{2}):([0-9]{2}):([0-9]{2}),([0-9]{3})', line)
regexp = '([0-9]{2}):([0-9]{2}):([0-9]{2}),([0-9]+) --> ([0-9]{2}):([0-9]{2}):([0-9]{2}),([0-9]+)' if re.search(regexp,line): m = re.search(regexp, line)
def GetSubtitleList(self, path): outputList = [] f = self.convertFile(path) #f = open(path, 'r') state = SubtitlesLoader.LOOK_FOR_ID for line in f: line = line.rstrip() line = line.decode("utf8")
beginTime = int(m.group(1))*1000*3600 beginTime += int(m.group(2))*1000*60 beginTime += int(m.group(3))*1000 beginTime += int(m.group(4))
beginMili = m.group(4) while len(beginMili) < 3: beginMili += "0"
def GetSubtitleList(self, path): outputList = [] f = self.convertFile(path) #f = open(path, 'r') state = SubtitlesLoader.LOOK_FOR_ID for line in f: line = line.rstrip() line = line.decode("utf8")
endTime = int(m.group(5))*1000*3600 endTime += int(m.group(6))*1000*60 endTime += int(m.group(7))*1000 endTime += int(m.group(8))
endMili = m.group(8) while len(endMili) < 3: endMili += "0"
def GetSubtitleList(self, path): outputList = [] f = self.convertFile(path) #f = open(path, 'r') state = SubtitlesLoader.LOOK_FOR_ID for line in f: line = line.rstrip() line = line.decode("utf8")
current.SetTimeBegin(beginTime) current.SetTimeEnd(endTime) current.SetText('') state = SubtitlesLoader.LOOK_FOR_TEXT
beginTime = int(m.group(1))*1000*3600 beginTime += int(m.group(2))*1000*60 beginTime += int(m.group(3))*1000 beginTime += int(beginMili) endTime = int(m.group(5))*1000*3600 endTime += int(m.group(6))*1000*60 endTime += int(m.group(7))*1000 endTime += int(endMili) current.SetTimeBegin(beginTime) current.SetTimeEnd(end...
def GetSubtitleList(self, path): outputList = [] f = self.convertFile(path) #f = open(path, 'r') state = SubtitlesLoader.LOOK_FOR_ID for line in f: line = line.rstrip() line = line.decode("utf8")
self.treeStoreDetails.append(None,["<b>"+_("Done path")+"</b>",exo.get_done_path()])
self.treeStoreDetails.append(None,["<b>"+_("Finished exercise path")+"</b>",exo.get_done_path()])
def _update_details_tree_view(self): print "_update_details_tree_view" self.treeStoreDetails = gtk.TreeStore(str,str)
else: print self.gui.config.Get("lastopenfile")
elif self.gui.config.Get("lastopenfile"): print "last open file : " + self.gui.config.Get("lastopenfile")
def run(self): if len(sys.argv) > 1: path = os.path.abspath(sys.argv[1]) self.core.LoadExercice( path ) else: print self.gui.config.Get("lastopenfile") self.core.LoadExercice(self.gui.config.Get("lastopenfile"))
wordList.append(word.getText())
wordList.append(word.getValid())
def ExtractWordList(self): wordList = []
raise NotImplementedError
pass
def update_after_write(self): "update after a modification of the text" raise NotImplementedError
self.updateWord(" ", 0, isEmpty=True)
self.UpdateWord(" ", 0, isEmpty=True)
def SetSequence(self, sequence): self.disableChangedTextEvent = True self.ClearBuffer() i = 0 pos = 1 cursor_pos = 0
self.updateWord(sequence.GetWordList()[i], 0, isFound=True)
self.UpdateWord(sequence.GetWordList()[i], 0, isFound=True)
def SetSequence(self, sequence): self.disableChangedTextEvent = True self.ClearBuffer() i = 0 pos = 1 cursor_pos = 0
self.updateWord(sequence.GetWorkList()[i], sequence.GetValidity(i))
self.UpdateWord(sequence.GetWorkList()[i], sequence.GetValidity(i))
def SetSequence(self, sequence): self.disableChangedTextEvent = True self.ClearBuffer() i = 0 pos = 1 cursor_pos = 0
def AddWordToFound(self, word, validity, isFound=False, isEmpty=False):
def UpdateWord(self, word, validity, isFound=False, isEmpty=False):
def AddWordToFound(self, word, validity, isFound=False, isEmpty=False): buffer = self.typeLabel.get_buffer() iter1 = buffer.get_end_iter() size = buffer.get_char_count() buffer.insert(iter1,word) iter1 = buffer.get_iter_at_offset(size) iter2 = buffer.get_end_iter()
path = result
def AskSavePath(self): saver = SaveFileSelector(self.window) path =saver.run() if path == None: return
outputList.append(current)
if len(current.get_text()) > 0: outputList.append(current)
def get_subtitle_list(self, path): outputList = [] f = self.convert_file(path) #f = open(path, 'r') state = SubtitlesLoader.LOOK_FOR_ID for line in f: line = line.rstrip() line = line.decode("utf8")
def first(self, testFunction, items, finalItem=None): """Return the name with the first item that match the test function. If impossible, match with finalItem test: item -> bool (for ex os.path.exists, os.path.isfile...) """ l=(i for i, item in enumerate(items) if testFunction(item)) try: firstItemIndex=l.next() e...
class Config: """Usage: config = Config() Warning: all keys must be lowercase""" def __init__(self): self._properties = {} self._writableParsers = [] def loadWritableConfigFile(self, writablePath, referencePath): """Load an ini config file that can be modified. Don't deal with file management""" parser = ConfigParser...
def first(self, testFunction, items, finalItem=None): #FIXME many paths """Return the name with the first item that match the test function. If impossible, match with finalItem test: item -> bool (for ex os.path.exists, os.path.isfile...) """ l=(i for i, item in enumerate(items) if testFunction(item)) try: firstIt...
class ConfigSingleton(object): """useful for gettexe""" _instance = None def __new__(cls): if cls._instance is None: cls._instance = object.__new__(cls) cls._instance.init() return cls._instance class configFile: def __init__(self, writablePath, referencePath): self.writablePath = writablePath self.referencePath = re...
for section in localParser.sections(): for (key, value) in localParser.items(section): parser.set(section, key, value)
def first(self, testFunction, items, finalItem=None): #FIXME many paths """Return the name with the first item that match the test function. If impossible, match with finalItem test: item -> bool (for ex os.path.exists, os.path.isfile...) """ l=(i for i, item in enumerate(items) if testFunction(item)) try: firstIt...
def getKeys(self): pass def save(self): pass class emptyConfig(ConfigSingleton): """usage: config = Config() Warning: all keys must be lowercase""" def init(self): self._properties = {} self._writableOptions = {} self._setLocalPaths(); configParser = self._loadConfigFiles() self._properties.update( dict(configParse...
for section in parser.sections(): for (key, value) in parser.items(section): self.Set(key, value) self._writableParsers.append((localParser, writableOptions, writablePath))
def getKeys(self): pass
if key in self._writableOptions.keys(): section = self._writableOptions[key] if not self._localConfigParser.has_section(section): self._localConfigParser.add_section(section) self._localConfigParser.set(section, key, value)
for (parser, writableOptions, _) in self._writableParsers: if key in writableOptions.keys(): section = writableOptions[key] if not parser.has_section(section): localParser.add_section(section) parser.set(section, key, value)
def Set(self, key, value): """Set a propertie""" if not key.islower(): raise KeyError, key+" is not lowercase"
if not os.path.exists(self.Get("localconfigdir")): os.mkdir( self.Get("localconfigdir") ) self._localConfigParser.write( open(self._localConfFilHref, "w")) def loadRepositorySources(self): localSourceFile = os.path.join( self.Get("localconfigdir"), "sources.conf") globalSourceFile = os.path.join( self.Get("globalconfi...
for (parser, _, path) in self._writableParsers: parser.write(path)
def Save(self): """Save the properties that have changed""" #FIXME: need to create the whole path, not only the final dir if not os.path.exists(self.Get("localconfigdir")): os.mkdir( self.Get("localconfigdir") ) self._localConfigParser.write( open(self._localConfFilHref, "w"))
for word in self.word_list: if re.search(filter_regexp, word): filtered_word_list.append(word)
if not self.core.get_exercise().is_lock_help(): for word in self.word_list: if re.search(filter_regexp, word): filtered_word_list.append(word)
def update_word_list(self): """Apply filter and send the new list to the gui"""
if not self.core.exercise.get_current_sequence().is_valid():
if not self.core.exercise.get_current_sequence().is_valid() and not self.core.get_exercise().is_lock_help():
def notify_key_press(self, keyname, shift, control): if keyname == "Return" or keyname == "KP_Enter": if not self.core.exercise.get_current_sequence().is_valid(): self.core.user_repeat() self.core.repeat_sequence() elif keyname == "BackSpace": if not self.core.exercise.get_current_sequence().is_valid(): self.core.delet...
elif keyname == "F2":
elif keyname == "F2" and not self.core.get_exercise().is_lock_help():
def notify_key_press(self, keyname, shift, control): if keyname == "Return" or keyname == "KP_Enter": if not self.core.exercise.get_current_sequence().is_valid(): self.core.user_repeat() self.core.repeat_sequence() elif keyname == "BackSpace": if not self.core.exercise.get_current_sequence().is_valid(): self.core.delet...