def command_mpd(self, args): args = shell_split(args) c = mpd.MPDClient() c.connect( host=self.config.get('host', 'localhost'), port=self.config.get('port', '6600')) password = self.config.get('password', '') if password: c.password(password) #pylint: disable=no-member current = c.currentsong() #pylint: disable=no-member artist = current.get('artist', 'Unknown artist') album = current.get('album', 'Unknown album') title = current.get('title', base( current.get('file', 'Unknown title'))) s = '%s - %s (%s)' % (artist, title, album) if 'full' in args: if 'elapsed' in current and 'time' in current: current_time = float(c.status()['elapsed']) #pylint: disable=no-member percents = int(current_time / float(current['time']) * 10) s += ' \x192}[\x191}' + '-' * ( percents - 1) + '\x193}+' + '\x191}' + '-' * ( 10 - percents - 1) + '\x192}]\x19o' if not self.api.send_message('%s' % (s, )): self.api.information('Cannot send result (%s)' % s, 'Error')
def move(src, dst, copy_function=shutil.copy2): """Recursively move a file or directory to another location. This is similar to the Unix "mv" command. Return the file or directory's destination. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination already exists but is not a directory, it may be overwritten depending on os.rename() semantics. If the destination is on our current filesystem, then rename() is used. Otherwise, src is copied to the destination and then removed. Symlinks are recreated under the new name if os.rename() fails because of cross filesystem renames. The optional `copy_function` argument is a callable that will be used to copy the source or it will be delegated to `copytree`. By default, copy2() is used, but any function that supports the same signature (like copy()) can be used. A lot more could be done here... A look at a mv.c shows a lot of the issues this implementation glosses over. """ real_dst = dst if isdir(dst): if samefile(src, dst): # We might be on a case insensitive filesystem, # perform the rename anyway. os.rename(src, dst) return real_dst = join(dst, base(src)) if exists(real_dst): raise Error("Destination path '%s' already exists" % real_dst) try: os.rename(src, real_dst) except OSError: if os.path.islink(src): linkto = os.readlink(src) os.symlink(linkto, real_dst) os.unlink(src) elif os.path.isdir(src): if ischild(src, dst): raise Error("Cannot move a directory '%s' into itself" " '%s'." % (src, dst)) shutil.copytree(src, real_dst, copy_function=copy_function, symlinks=True) shutil.rmtree(src) else: copy_function(src, real_dst) os.unlink(src) return real_dst
def __init__(self, transcriptome_fn, database_fn, output_fn=None, cutoff=.00001, n_threads=1, n_nodes=None, use_existing_db=None): self.transcriptome_fn = transcriptome_fn self.renamed_fn = self.transcriptome_fn + '.renamed' self.name_map_fn = self.transcriptome_fn + '.names.csv' self.translated_fn = self.renamed_fn + '.pep' self.database_fn = database_fn self.renamed_database_fn = self.database_fn + '.renamed' self.database_name_map_fn = self.database_fn + '.names.csv' self.n_threads = n_threads self.cutoff = cutoff self.use_existing_db = use_existing_db self.db_x_translated_fn = '{0}.x.{1}.maf'.format(base(self.renamed_database_fn), base(self.translated_fn)) self.translated_x_db_fn = '{0}.x.{1}.maf'.format(base(self.translated_fn), base(self.renamed_database_fn)) self.output_fn = output_fn if self.output_fn is None: self.output_prefix = '{0}.x.{1}.rbl'.format(base(self.transcriptome_fn), base(self.database_fn)) self.unmapped_output_fn = self.output_prefix + '.unmapped.csv' self.output_fn = self.output_prefix + '.csv' self.bh = BestHits(comparison_cols=['E', 'EG2'])
def Automatic_Tracking(self): """ function takes (the trimmed in time) videofiles and launches flytracker to track them. """ from os.path import basename as base # see function get_fname for clarification on base eng = matlab.engine.start_matlab() # import matlab engine # for each of the videos, launch Logans auto_track.m matlab script which inputs these # variables into the Flytracker matlab script tracker.m for f_vid in self.matlab_vid_paths: # define matlab inputs self.f_vid = f_vid self.f_calib = self.f_vid[:-4] + '_calibration.mat' """ THE LINE BELOW IS THE PROBLEM CHILD """ self.root = os.path.dirname(self.f_vid) + '\\' # Launch Fly Tracker Tracking eng.auto_track( {self.root}, base(self.f_vid), self.f_calib, nargout=0 ) # no matlab argument outputs, else code drowns in a sea of errors """ THIS IS WHAT LOGAN THINKS THE LINE SHOULD BE!!!!! # Launch Fly Tracker Tracking eng.auto_track({os.path.dirname(self.f_vid) + '\\'}, base(self.f_vid), self.f_calib, nargout=0) # no matlab argument outputs, else code drowns in a sea of errors """ # Move the video file once you're done tracking it into the folder JAABA needs it to be in os.rename( self.f_vid, self.root + base(self.f_vid)[:-4] + '\\' + base(self.f_vid)) # Add the renamed path above to a list for later use by JAABA self.output_list.append(self.root + base(self.f_vid)[:-4] + '\\' + base(self.f_vid)) try: # exit matlab eng.quit() except: # weak error exception = bad programming logan pass
def __init__(self, transcriptome_fn, database_fn, output_fn=None, model_fn=None, cutoff=.00001, n_threads=1, use_existing_db=True): self.crbl_output_fn = output_fn self.crbl_output_prefix = output_fn if output_fn is None: self.crbl_output_prefix = '{0}.x.{1}.crbl'.format(base(transcriptome_fn), base(database_fn)) self.crbl_output_fn = self.crbl_output_prefix + '.csv' self.unmapped_crbl_output_fn = self.crbl_output_prefix + '.unmapped.csv' self.model_fn = model_fn if model_fn is None: self.model_fn = self.crbl_output_prefix + '.model.csv' self.model_plot_fn = self.model_fn + '.plot.pdf' super(CRBL, self).__init__(transcriptome_fn, database_fn, output_fn=None, cutoff=cutoff, n_threads=n_threads, use_existing_db=use_existing_db)
def image_intercept(bbox_geojson, image_folder, out_folder, image_id_field, create_subset=False): gdf = gpd.read_file(bbox_geojson) unique = gdf[image_id_field].unique() if create_subset == True: for i in image_id_field: src = op(image_folder, i) dst = op(subset_folder, i) copyfile(src, dst) with open(op(out_folder, sp(base(bbox_geojson))[0] + "_images.csv"), 'w') as f: writer = csv.writer(f) writer.writerows(zip(unique))
def __init__(self, image_name=None, user_id=None): self.image_name = image_name self.path_to_img_translation = create_path(split(base(image_name))[0]+"_translation") self.langs = {'es':'spanish','fr':'french','en':'english','du':'dutch'}
def __init__(self, image_name=None, user_id=None): self.image_name = image_name self.path_to_img_translation = create_path(split(base(image_name))[0] + "_translation") self.langs = {"es": "spanish", "fr": "french", "en": "english", "du": "dutch"}