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 sha_image.update(buf) return (image_size, hexlify(sha_image.digest())) |
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 sha_image.update(buf) return (image_size, hexlify(sha_image.digest())) |
|
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_opt = 's' self.access_key_opt = 'a' if not short_opts: short_opts = '' if not long_opts: long_opts = [''] short_opts += 'hU:' short_opts += '%s:' % self.secret_key_opt short_opts += '%s:' % self.access_key_opt long_opts += [ 'access-key=', 'secret-key=', 'url=', 'help', 'version', 'debug', 'config=', ] (opts, args) = getopt.gnu_getopt(sys.argv[1:], short_opts, long_opts) self.opts = opts self.args = args self.debug = False for (name, value) in opts: if name in ('-%s' % self.access_key_opt, '--access-key'): self.ec2_user_access_key = value elif name in ('-%s' % self.secret_key_opt, '--secret-key'): try: self.ec2_user_secret_key = int(value) self.ec2_user_secret_key = None except ValueError: self.ec2_user_secret_key = value elif name in ('-U', '--url'): self.ec2_url = value elif name == '--debug': self.debug = True elif name == '--config': self.config_file_path = value system_string = platform.system() if system_string == 'Linux': self.img = LinuxImage(self.debug) elif system_string == 'SunOS': self.img = SolarisImage(self.debug) else: self.img = 'Unsupported' self.setup_environ() |
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_opt = 's' self.access_key_opt = 'a' if not short_opts: short_opts = '' if not long_opts: long_opts = [''] short_opts += 'hU:' short_opts += '%s:' % self.secret_key_opt short_opts += '%s:' % self.access_key_opt long_opts += [ 'access-key=', 'secret-key=', 'url=', 'help', 'version', 'debug', 'config=', ] (opts, args) = getopt.gnu_getopt(sys.argv[1:], short_opts, long_opts) self.opts = opts self.args = args self.debug = False for (name, value) in opts: if name in ('-%s' % self.access_key_opt, '--access-key'): self.ec2_user_access_key = value elif name in ('-%s' % self.secret_key_opt, '--secret-key'): try: self.ec2_user_secret_key = int(value) self.ec2_user_secret_key = None except ValueError: self.ec2_user_secret_key = value elif name in ('-U', '--url'): self.ec2_url = value elif name == '--debug': self.debug = True elif name == '--config': self.config_file_path = value system_string = platform.system() if system_string == 'Linux': self.img = LinuxImage(self.debug) elif system_string == 'SunOS': self.img = SolarisImage(self.debug) else: self.img = 'Unsupported' self.setup_environ() |
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].startswith('snap'): block_dev_type.snapshot_id = value_parts[0] else: if value_parts[0].startswith('ephemeral'): block_dev_type.ephemeral_name = value_parts[0] if len(value_parts) > 1: block_dev_type.size = int(value_parts[1]) if len(value_parts) > 2: if value_parts[2] == 'true': block_dev_type.delete_on_termination = True block_device_map[device_name] = block_dev_type return block_device_map |
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: self.ms.close() self.ms = None continue else: print "ERROR: ", message[1] elif message[0] == cwiid.MESG_ACC: state["acc"] = message[1] else: print "Unknown message!", message laststate = self.laststate if ('buttons' in laststate) and (laststate['buttons'] <> state['buttons']): if state['buttons'] == 0: self.maxButtons = 0 elif state['buttons'] < self.maxButtons: continue else: self.maxButtons = state['buttons'] self.lasttime = 0 self.firstPress = True if laststate['buttons'] == cwiid.BTN_B and not state['buttons'] == cwiid.BTN_B: del state['BTN_B'] self.ms.cmd('play speed normal') if (laststate['buttons'] & cwiid.BTN_A and laststate['buttons'] & cwiid.BTN_B) and not (state['buttons'] & cwiid.BTN_A and state['buttons'] & cwiid.BTN_B): del state['BTN_AB'] #self.ms.cmd('play speed normal') if self.ms.ok() and (self.wm is not None) and (state["buttons"] > 0) and (time.time() > self.lasttime+self.responsiveness): self.lasttime = time.time() wasFirstPress = False if self.firstPress: wasFirstPress = True self.lasttime = self.lasttime + self.firstPressDelay self.firstPress = False # Stuff that doesn't need roll/etc calculations if state["buttons"] == cwiid.BTN_HOME: self.ms.cmd('key escape') if state["buttons"] == cwiid.BTN_A: self.ms.cmd('key enter') if state["buttons"] == cwiid.BTN_MINUS: self.ms.cmd('key d') if state["buttons"] == cwiid.BTN_UP: self.ms.cmd('key up') if state["buttons"] == cwiid.BTN_DOWN: self.ms.cmd('key down') if state["buttons"] == cwiid.BTN_LEFT: self.ms.cmd('key left') if state["buttons"] == cwiid.BTN_RIGHT: self.ms.cmd('key right') if state["buttons"] == cwiid.BTN_PLUS: self.ms.cmd('key p') if state["buttons"] == cwiid.BTN_1: self.ms.cmd('key i') if state["buttons"] == cwiid.BTN_2: self.ms.cmd('key m') # Do we need to calculate roll, etc? # Currently only BTN_B needs this. calcAcc = state["buttons"] & cwiid.BTN_B if calcAcc: # Calculate the roll/etc. X = self.wii_rel(state["acc"][cwiid.X], cwiid.X) Y = self.wii_rel(state["acc"][cwiid.Y], cwiid.Y) Z = self.wii_rel(state["acc"][cwiid.Z], cwiid.Z) if (Z==0): Z=0.00000001 # Hackishly prevents divide by zeros roll = atan(X/Z) if (Z <= 0.0): if (X>0): roll += 3.14159 else: roll -= 3.14159 pitch = atan(Y/Z*cos(roll)) #print "X: %f, Y: %f, Z: %f; R: %f, P: %f; B: %d \r" % (X, Y, Z, roll, pitch, state["buttons"]), sys.stdout.flush() if state["buttons"] & cwiid.BTN_B and state["buttons"] & cwiid.BTN_LEFT: self.ms.cmd('play seek beginning') if state["buttons"] & cwiid.BTN_B and state["buttons"] & cwiid.BTN_A: speed=do_scale(roll/3.14159, 20, 25) if (speed<-10): speed = -10 state['BTN_AB'] = speed cmd = "" # on first press, press a, # after then use the diff to press left/right if not 'BTN_AB' in laststate: # # query location # Playback Recorded 00:04:20 of 00:25:31 1x 30210 2008-09-10T09:18:00 6523 /video/30210_20080910091800.mpg 25 cmd += "play speed normal\nkey a\n"#"play speed normal\n" else: speed = speed - laststate['BTN_AB'] if speed > 0: cmd += abs(speed)*"key right\n" elif speed < 0: cmd += abs(speed)*"key left\n" if speed <> 0: self.wm.rumble=1 time.sleep(.05) self.wm.rumble=0 if cmd is not None and cmd: self.ms.raw(cmd) if state["buttons"] == cwiid.BTN_B: speed=do_scale(roll/3.14159, 8, 13) state['BTN_B'] = speed if not 'BTN_B' in laststate: # # query location # Playback Recorded 00:04:20 of 00:25:31 1x 30210 2008-09-10T09:18:00 6523 /video/30210_20080910091800.mpg 25 cmd = ""#"play speed normal\n" if speed > 0: cmd += "key .\n" elif speed < 0: cmd += "key ,\n" if speed <> 0: cmd += "key "+str(abs(speed)-1)+"\n" #print cmd elif laststate['BTN_B']<>speed: self.wm.rumble=1 time.sleep(.05) self.wm.rumble=0 if speed == 0: cmd = "play speed normal" elif ((laststate['BTN_B'] > 0) and (speed > 0)) or ((laststate['BTN_B'] < 0) and (speed < 0)): cmd = "key "+str(abs(speed)-1)+"\n" elif speed>0: cmd = "key .\nkey "+str(abs(speed)-1)+"\n" else: cmd = "key ,\nkey "+str(abs(speed)-1)+"\n" else: cmd = None if cmd is not None: self.ms.raw(cmd) self.laststate = state.copy() #NOTE TO SELF: REMEMBER .copy() !!! |
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: self.ms.close() self.ms = None continue else: print "ERROR: ", message[1] elif message[0] == cwiid.MESG_ACC: state["acc"] = message[1] else: print "Unknown message!", message laststate = self.laststate if ('buttons' in laststate) and (laststate['buttons'] <> state['buttons']): if state['buttons'] == 0: self.maxButtons = 0 elif state['buttons'] < self.maxButtons: continue else: self.maxButtons = state['buttons'] self.lasttime = 0 self.firstPress = True if laststate['buttons'] == cwiid.BTN_B and not state['buttons'] == cwiid.BTN_B: del state['BTN_B'] self.ms.cmd('play speed normal') if (laststate['buttons'] & cwiid.BTN_A and laststate['buttons'] & cwiid.BTN_B) and not (state['buttons'] & cwiid.BTN_A and state['buttons'] & cwiid.BTN_B): del state['BTN_AB'] #self.ms.cmd('play speed normal') if self.ms.ok() and (self.wm is not None) and (state["buttons"] > 0) and (time.time() > self.lasttime+self.responsiveness): self.lasttime = time.time() wasFirstPress = False if self.firstPress: wasFirstPress = True self.lasttime = self.lasttime + self.firstPressDelay self.firstPress = False # Stuff that doesn't need roll/etc calculations if state["buttons"] == cwiid.BTN_HOME: self.ms.cmd('key escape') if state["buttons"] == cwiid.BTN_A: self.ms.cmd('key enter') if state["buttons"] == cwiid.BTN_MINUS: self.ms.cmd('key d') if state["buttons"] == cwiid.BTN_UP: self.ms.cmd('key up') if state["buttons"] == cwiid.BTN_DOWN: self.ms.cmd('key down') if state["buttons"] == cwiid.BTN_LEFT: self.ms.cmd('key left') if state["buttons"] == cwiid.BTN_RIGHT: self.ms.cmd('key right') if state["buttons"] == cwiid.BTN_PLUS: self.ms.cmd('key p') if state["buttons"] == cwiid.BTN_1: self.ms.cmd('key i') if state["buttons"] == cwiid.BTN_2: self.ms.cmd('key m') # Do we need to calculate roll, etc? # Currently only BTN_B needs this. calcAcc = state["buttons"] & cwiid.BTN_B if calcAcc: # Calculate the roll/etc. X = self.wii_rel(state["acc"][cwiid.X], cwiid.X) Y = self.wii_rel(state["acc"][cwiid.Y], cwiid.Y) Z = self.wii_rel(state["acc"][cwiid.Z], cwiid.Z) if (Z==0): Z=0.00000001 # Hackishly prevents divide by zeros roll = atan(X/Z) if (Z <= 0.0): if (X>0): roll += 3.14159 else: roll -= 3.14159 pitch = atan(Y/Z*cos(roll)) #print "X: %f, Y: %f, Z: %f; R: %f, P: %f; B: %d \r" % (X, Y, Z, roll, pitch, state["buttons"]), sys.stdout.flush() if state["buttons"] & cwiid.BTN_B and state["buttons"] & cwiid.BTN_LEFT: self.ms.cmd('play seek beginning') if state["buttons"] & cwiid.BTN_B and state["buttons"] & cwiid.BTN_A: speed=do_scale(roll/3.14159, 20, 25) if (speed<-10): speed = -10 state['BTN_AB'] = speed cmd = "" # on first press, press a, # after then use the diff to press left/right if not 'BTN_AB' in laststate: # # query location # Playback Recorded 00:04:20 of 00:25:31 1x 30210 2008-09-10T09:18:00 6523 /video/30210_20080910091800.mpg 25 cmd += "play speed normal\nkey a\n"#"play speed normal\n" else: speed = speed - laststate['BTN_AB'] if speed > 0: cmd += abs(speed)*"key right\n" elif speed < 0: cmd += abs(speed)*"key left\n" if speed <> 0: self.wm.rumble=1 time.sleep(.05) self.wm.rumble=0 if cmd is not None and cmd: self.ms.raw(cmd) if state["buttons"] == cwiid.BTN_B: speed=do_scale(roll/3.14159, 8, 13) state['BTN_B'] = speed if not 'BTN_B' in laststate: # # query location # Playback Recorded 00:04:20 of 00:25:31 1x 30210 2008-09-10T09:18:00 6523 /video/30210_20080910091800.mpg 25 cmd = ""#"play speed normal\n" if speed > 0: cmd += "key .\n" elif speed < 0: cmd += "key ,\n" if speed <> 0: cmd += "key "+str(abs(speed)-1)+"\n" #print cmd elif laststate['BTN_B']<>speed: self.wm.rumble=1 time.sleep(.05) self.wm.rumble=0 if speed == 0: cmd = "play speed normal" elif ((laststate['BTN_B'] > 0) and (speed > 0)) or ((laststate['BTN_B'] < 0) and (speed < 0)): cmd = "key "+str(abs(speed)-1)+"\n" elif speed>0: cmd = "key .\nkey "+str(abs(speed)-1)+"\n" else: cmd = "key ,\nkey "+str(abs(speed)-1)+"\n" else: cmd = None if cmd is not None: self.ms.raw(cmd) self.laststate = state.copy() #NOTE TO SELF: REMEMBER .copy() !!! |
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: self.ms.close() self.ms = None continue else: print "ERROR: ", message[1] elif message[0] == cwiid.MESG_ACC: state["acc"] = message[1] else: print "Unknown message!", message laststate = self.laststate if ('buttons' in laststate) and (laststate['buttons'] <> state['buttons']): if state['buttons'] == 0: self.maxButtons = 0 elif state['buttons'] < self.maxButtons: continue else: self.maxButtons = state['buttons'] self.lasttime = 0 self.firstPress = True if laststate['buttons'] == cwiid.BTN_B and not state['buttons'] == cwiid.BTN_B: del state['BTN_B'] self.ms.cmd('play speed normal') if (laststate['buttons'] & cwiid.BTN_A and laststate['buttons'] & cwiid.BTN_B) and not (state['buttons'] & cwiid.BTN_A and state['buttons'] & cwiid.BTN_B): del state['BTN_AB'] #self.ms.cmd('play speed normal') if self.ms.ok() and (self.wm is not None) and (state["buttons"] > 0) and (time.time() > self.lasttime+self.responsiveness): self.lasttime = time.time() wasFirstPress = False if self.firstPress: wasFirstPress = True self.lasttime = self.lasttime + self.firstPressDelay self.firstPress = False # Stuff that doesn't need roll/etc calculations if state["buttons"] == cwiid.BTN_HOME: self.ms.cmd('key escape') if state["buttons"] == cwiid.BTN_A: self.ms.cmd('key enter') if state["buttons"] == cwiid.BTN_MINUS: self.ms.cmd('key d') if state["buttons"] == cwiid.BTN_UP: self.ms.cmd('key up') if state["buttons"] == cwiid.BTN_DOWN: self.ms.cmd('key down') if state["buttons"] == cwiid.BTN_LEFT: self.ms.cmd('key left') if state["buttons"] == cwiid.BTN_RIGHT: self.ms.cmd('key right') if state["buttons"] == cwiid.BTN_PLUS: self.ms.cmd('key p') if state["buttons"] == cwiid.BTN_1: self.ms.cmd('key i') if state["buttons"] == cwiid.BTN_2: self.ms.cmd('key m') # Do we need to calculate roll, etc? # Currently only BTN_B needs this. calcAcc = state["buttons"] & cwiid.BTN_B if calcAcc: # Calculate the roll/etc. X = self.wii_rel(state["acc"][cwiid.X], cwiid.X) Y = self.wii_rel(state["acc"][cwiid.Y], cwiid.Y) Z = self.wii_rel(state["acc"][cwiid.Z], cwiid.Z) if (Z==0): Z=0.00000001 # Hackishly prevents divide by zeros roll = atan(X/Z) if (Z <= 0.0): if (X>0): roll += 3.14159 else: roll -= 3.14159 pitch = atan(Y/Z*cos(roll)) #print "X: %f, Y: %f, Z: %f; R: %f, P: %f; B: %d \r" % (X, Y, Z, roll, pitch, state["buttons"]), sys.stdout.flush() if state["buttons"] & cwiid.BTN_B and state["buttons"] & cwiid.BTN_LEFT: self.ms.cmd('play seek beginning') if state["buttons"] & cwiid.BTN_B and state["buttons"] & cwiid.BTN_A: speed=do_scale(roll/3.14159, 20, 25) if (speed<-10): speed = -10 state['BTN_AB'] = speed cmd = "" # on first press, press a, # after then use the diff to press left/right if not 'BTN_AB' in laststate: # # query location # Playback Recorded 00:04:20 of 00:25:31 1x 30210 2008-09-10T09:18:00 6523 /video/30210_20080910091800.mpg 25 cmd += "play speed normal\nkey a\n"#"play speed normal\n" else: speed = speed - laststate['BTN_AB'] if speed > 0: cmd += abs(speed)*"key right\n" elif speed < 0: cmd += abs(speed)*"key left\n" if speed <> 0: self.wm.rumble=1 time.sleep(.05) self.wm.rumble=0 if cmd is not None and cmd: self.ms.raw(cmd) if state["buttons"] == cwiid.BTN_B: speed=do_scale(roll/3.14159, 8, 13) state['BTN_B'] = speed if not 'BTN_B' in laststate: # # query location # Playback Recorded 00:04:20 of 00:25:31 1x 30210 2008-09-10T09:18:00 6523 /video/30210_20080910091800.mpg 25 cmd = ""#"play speed normal\n" if speed > 0: cmd += "key .\n" elif speed < 0: cmd += "key ,\n" if speed <> 0: cmd += "key "+str(abs(speed)-1)+"\n" #print cmd elif laststate['BTN_B']<>speed: self.wm.rumble=1 time.sleep(.05) self.wm.rumble=0 if speed == 0: cmd = "play speed normal" elif ((laststate['BTN_B'] > 0) and (speed > 0)) or ((laststate['BTN_B'] < 0) and (speed < 0)): cmd = "key "+str(abs(speed)-1)+"\n" elif speed>0: cmd = "key .\nkey "+str(abs(speed)-1)+"\n" else: cmd = "key ,\nkey "+str(abs(speed)-1)+"\n" else: cmd = None if cmd is not None: self.ms.raw(cmd) self.laststate = state.copy() #NOTE TO SELF: REMEMBER .copy() !!! |
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_NAME = 'OpenBmap uploaded logs directory name' self.OBM_UPLOAD_URL = 'OpenBmap upload URL' self.OBM_API_CHECK_URL = 'OpenBmap API check URL' self.OBM_API_VERSION = 'OpenBmap API version' self.SCAN_SPEED_DEFAULT = 'OpenBmap logger default scanning speed (in sec.)' self.MIN_SPEED_FOR_LOGGING = 'GPS minimal speed for logging (km/h)' self.MAX_SPEED_FOR_LOGGING = 'GPS maximal speed for logging (km/h)' # NB_OF_LOGS_PER_FILE is considered for writing of log to disk only if MAX_LOGS_FILE_SIZE <= 0 self.NB_OF_LOGS_PER_FILE = 'Number of logs per file' # puts sth <=0 to MAX_LOGS_FILE_SIZE to ignore it and let other conditions trigger # the write of the log to disk (e.g. NB_OF_LOGS_PER_FILE) self.MAX_LOGS_FILE_SIZE = 'Maximal size of log files to be uploaded (kbytes)' self.APP_LOGGING_LEVEL = 'Application logging level (debug, info, warning, error, critical)' self.LIST_OF_ACTIVE_PLUGINS = 'List of active plugins (try to load them at startup)' |
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: # GSM plugin is not running if len(self._activePluginScheduledIds) > 0: # we check if plugin(s) is(are) scheduled logging.debug('Plugin(s) are still scheduled.') result = True else: # we check every plugin is not currently working for plugin in self._activePluginsList: result = plugin.is_working() logging.debug('Is the plugin %s running? %s' % (plugin.get_id(), result and 'Yes' or 'No') ) if result: # this plugin is working break self._loggerLock.release() logging.debug('OBM logger lock released by is_logging().') return 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: # GSM plugin is not running if len(self._activePluginScheduledIds) > 0: # we check if plugin(s) is(are) scheduled logging.debug('Plugin(s) are still scheduled.') result = True else: # we check every plugin is not currently working for plugin in self._activePluginsList: result = plugin.is_working() logging.debug('Is the plugin %s running? %s' % (plugin.get_id(), result and 'Yes' or 'No') ) if result: # this plugin is working break self._loggerLock.release() logging.debug('OBM logger lock released by is_logging().') return 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: # GSM plugin is not running if len(self._activePluginScheduledIds) > 0: # we check if plugin(s) is(are) scheduled logging.debug('Plugin(s) are still scheduled.') result = True else: # we check every plugin is not currently working for plugin in self._activePluginsList: result = plugin.is_working() logging.debug('Is the plugin %s running? %s' % (plugin.get_id(), result and 'Yes' or 'No') ) if result: # this plugin is working break self._loggerLock.release() logging.debug('OBM logger lock released by is_logging().') return 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() except Exception, e2: logging.error(e2) data = [] | 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').GetInfo() if 'manufacturer' in data: # At the moment the returned string starts and ends with '"' for model and revision self._manufacturer = data['manufacturer'].strip('"') if 'model' in data: # At the moment the returned string starts and ends with '"' for model and revision self._model = data['model'].strip('"') if 'revision' in data: # At the moment the returned string starts and ends with '"' for model and revision self._revision = data['revision'].strip('"') logging.info('Hardware manufacturer=%s, model=%s, revision=%s.' % \ (self._manufacturer, self._model, self._revision)) return(self._manufacturer, self._model, self._revision) |
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.path.expanduser("~"), "perroquet_config") if os.path.isfile(os.path.join(self.properties["script"], 'data/perroquet.ui')): self.properties["ui_path"] = os.path.join(self.properties["script"], 'data/perroquet.ui') elif os.path.isfile(os.path.join(self.properties["script"], '../share/perroquet/perroquet.ui')): self.properties["ui_path"] = os.path.join(self.properties["script"], '../share/perroquet/perroquet.ui') else: print "Error : gui file 'perroquet.ui' not found" sys.exit(1) |
|
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 containing url list repositoryPathList = config.get("repository_source_list") repositoryList = [] offlineRepoList = [] |
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, value) |
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, value) |
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, value) |
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.pathListStore.get_value(self.iterPath, 1), self.pathListStore.get_value(self.iterPath, 2), self.pathListStore.get_value(self.iterPath, 3)]) | 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.iterPath,3) ]) self.iterPath = None self.treeviewSelectionPathsList.select_iter(iter) |
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(str) for file in self.config.Get("lastopenfiles"): print file treeStore.append(None, [file]) gtkTree.set_model(treeStore) |
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_CONFIRMATION_ACCEPT_FILENAME | 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_id(self.windowId) #self.activate_video_area(True) gtk.gdk.threads_leave() |
|
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(endTime) current.SetText('') state = SubtitlesLoader.LOOK_FOR_TEXT | 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() except StopIteration: if finalItem: return finalItem else: raise IOError, "Error : "+name+" not found" else: return items[firstItemIndex] | 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.ConfigParser() localParser = ConfigParser.ConfigParser() parser.read(referencePath) localParser.read(writablePath) writableOptions = dict([(option, section) for section in parser.sections() for option in parser.options(section) ]) | 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: firstItemIndex=l.next() except StopIteration: if finalItem: return finalItem else: raise IOError, "Error : "+name+" not found" else: return items[firstItemIndex] |
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 = referencePath | 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: firstItemIndex=l.next() except StopIteration: if finalItem: return finalItem else: raise IOError, "Error : "+name+" not found" else: return items[firstItemIndex] |
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(configParser.items("string")) ) self._properties.update( dict( ((s, int(i)) for (s,i) in configParser.items("int")) )) def loadConfigFile(self, writablePath=None, referencePath): """Load an ini config file""" configParser = ConfigParser.ConfigParser() if os.path.isfile(self._globalConfFilHref): configParser.read(self._globalConfFilHref) elif os.path.isfile(os.path.join(self.Get("script"), 'data/config')): configParser.read(os.path.join(self.Get("script"), 'data/config')) else: raise IOError, "Error : global conf file 'config' not found at "+ os.path.join(self.Get("script"), 'data/config') self._localConfigParser = ConfigParser.ConfigParser() if len( self._localConfigParser.read(self._localConfFilHref)) == 0: print "No local conf file find" self._writableOptions = dict([(option, section) for section in configParser.sections() for option in configParser.options(section) ]) for section in self._localConfigParser.sections(): for (key, value) in self._localConfigParser.items(section): configParser.set(section, key, value) return configParser | 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("globalconfigdir"), "sources.conf") scriptSourceFile = os.path.join( self.Get("script"), "data/sources.conf") sourcePathList = [] if os.path.isfile(scriptSourceFile): sourcePathList.append(scriptSourceFile) if os.path.isfile(globalSourceFile): sourcePathList.append(globalSourceFile) if os.path.isfile(localSourceFile): sourcePathList.append(localSourceFile) self.Set("repository_source_list", os.path.join(sourcePathList)) self.Set("personal_repository_source_path", localSourceFile) | 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.delete_previous_char() elif keyname == "Delete": if not self.core.exercise.get_current_sequence().is_valid(): self.core.delete_next_char() elif keyname == "Page_Down": self.core.previous_sequence() elif keyname == "Page_Up": self.core.next_sequence() elif keyname == "Down": self.core.previous_sequence() elif keyname == "Up": self.core.next_sequence() elif keyname == "Tab": if not self.core.exercise.get_current_sequence().is_valid(): self.core.next_word() elif keyname == "ISO_Left_Tab": if not self.core.exercise.get_current_sequence().is_valid(): self.core.previous_word() elif keyname == "F1": if not self.core.exercise.get_current_sequence().is_valid(): if shift and control: self.core.reveal_sequence() elif shift: self.core.reveal_word() else: self.core.complete_word() elif keyname == "F2": self.toggle_translation() elif keyname == "F9": self.toggle_lateral_panel() elif keyname == "Pause": self.core.toggle_pause() elif keyname == "KP_Add": if self.current_speed > 0.9: self.core.set_speed(1.0) else: self.core.set_speed(self.current_speed + 0.1) elif keyname == "KP_Subtract": if self.current_speed < 0.85: self.core.set_speed(0.75) else: self.core.set_speed(self.current_speed-0.1) else: return False |
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.delete_previous_char() elif keyname == "Delete": if not self.core.exercise.get_current_sequence().is_valid(): self.core.delete_next_char() elif keyname == "Page_Down": self.core.previous_sequence() elif keyname == "Page_Up": self.core.next_sequence() elif keyname == "Down": self.core.previous_sequence() elif keyname == "Up": self.core.next_sequence() elif keyname == "Tab": if not self.core.exercise.get_current_sequence().is_valid(): self.core.next_word() elif keyname == "ISO_Left_Tab": if not self.core.exercise.get_current_sequence().is_valid(): self.core.previous_word() elif keyname == "F1": if not self.core.exercise.get_current_sequence().is_valid(): if shift and control: self.core.reveal_sequence() elif shift: self.core.reveal_word() else: self.core.complete_word() elif keyname == "F2": self.toggle_translation() elif keyname == "F9": self.toggle_lateral_panel() elif keyname == "Pause": self.core.toggle_pause() elif keyname == "KP_Add": if self.current_speed > 0.9: self.core.set_speed(1.0) else: self.core.set_speed(self.current_speed + 0.1) elif keyname == "KP_Subtract": if self.current_speed < 0.85: self.core.set_speed(0.75) else: self.core.set_speed(self.current_speed-0.1) else: return False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.