def main(target, recursive = False, verbose = False, confirm = False): # add code here if __name__ == '__main__': args = core.parse_args(sys.argv) if(args != None): main(args['target'], args['recursive'], args['verbose'], args['confirm'])
def main(args): # Initialize the config core.initialize() # clientAgent for Torrents client_agent = core.TORRENT_CLIENTAGENT logger.info('#########################################################') logger.info('## ..::[{0}]::.. ##'.format(os.path.basename(__file__))) logger.info('#########################################################') # debug command line options logger.debug('Options passed into TorrentToMedia: {0}'.format(args)) # Post-Processing Result result = ProcessResult( message='', status_code=0, ) try: input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args) except Exception: logger.error('There was a problem loading variables') return -1 if input_directory and input_name and input_hash and input_id: result = process_torrent(input_directory, input_name, input_category, input_hash, input_id, client_agent) else: # Perform Manual Post-Processing logger.warning('Invalid number of arguments received from client, Switching to manual run mode ...') for section, subsections in core.SECTIONS.items(): for subsection in subsections: if not core.CFG[section][subsection].isenabled(): continue for dir_name in core.get_dirs(section, subsection, link='hard'): logger.info('Starting manual run for {0}:{1} - Folder:{2}'.format (section, subsection, dir_name)) logger.info('Checking database for download info for {0} ...'.format (os.path.basename(dir_name))) core.DOWNLOADINFO = core.get_download_info(os.path.basename(dir_name), 0) if core.DOWNLOADINFO: client_agent = text_type(core.DOWNLOADINFO[0].get('client_agent', 'manual')) input_hash = text_type(core.DOWNLOADINFO[0].get('input_hash', '')) input_id = text_type(core.DOWNLOADINFO[0].get('input_id', '')) logger.info('Found download info for {0}, ' 'setting variables now ...'.format(os.path.basename(dir_name))) else: logger.info('Unable to locate download info for {0}, ' 'continuing to try and process this release ...'.format (os.path.basename(dir_name))) client_agent = 'manual' input_hash = '' input_id = '' if client_agent.lower() not in core.TORRENT_CLIENTS: continue try: dir_name = dir_name.encode(core.SYS_ENCODING) except UnicodeError: pass input_name = os.path.basename(dir_name) try: input_name = input_name.encode(core.SYS_ENCODING) except UnicodeError: pass results = process_torrent(dir_name, input_name, subsection, input_hash or None, input_id or None, client_agent) if results.status_code != 0: logger.error('A problem was reported when trying to perform a manual run for {0}:{1}.'.format (section, subsection)) result = results if result.status_code == 0: logger.info('The {0} script completed successfully.'.format(args[0])) else: logger.error('A problem was reported in the {0} script.'.format(args[0])) del core.MYAPP return result.status_code
def main(): args = parse_args() train_model_ewc(ModelNet40, TASKS, args.sampling, args.z_size, args.batch_norm, args.verbose, args.max_epochs, args.batch_size, args.lr, args.patience, args.alpha)
def main(args): # Initialize the config core.initialize() # clientAgent for Torrents clientAgent = core.TORRENT_CLIENTAGENT logger.info("#########################################################") logger.info("## ..::[%s]::.. ##" % os.path.basename(__file__)) logger.info("#########################################################") # debug command line options logger.debug("Options passed into TorrentToMedia: %s" % (args)) # Post-Processing Result result = [ 0, "" ] try: inputDirectory, inputName, inputCategory, inputHash, inputID = core.parse_args(clientAgent, args) except: logger.error("There was a problem loading variables") return -1 if inputDirectory and inputName and inputHash and inputID: result = processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, clientAgent) else: # Perform Manual Post-Processing logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...") for section, subsections in core.SECTIONS.items(): for subsection in subsections: if not core.CFG[section][subsection].isenabled(): continue for dirName in core.getDirs(section, subsection, link='hard'): logger.info("Starting manual run for %s:%s - Folder:%s" % (section, subsection, dirName)) logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName))) core.DOWNLOADINFO = core.get_downloadInfo(os.path.basename(dirName), 0) if core.DOWNLOADINFO: logger.info( "Found download info for %s, setting variables now ..." % (os.path.basename(dirName))) else: logger.info( 'Unable to locate download info for %s, continuing to try and process this release ...' % ( os.path.basename(dirName)) ) try: clientAgent = str(core.DOWNLOADINFO[0]['client_agent']) except: clientAgent = 'manual' try: inputHash = str(core.DOWNLOADINFO[0]['input_hash']) except: inputHash = None try: inputID = str(core.DOWNLOADINFO[0]['input_id']) except: inputID = None if clientAgent.lower() not in core.TORRENT_CLIENTS and clientAgent != 'manual': continue try: dirName = dirName.encode(core.SYS_ENCODING) except: pass inputName = os.path.basename(dirName) try: inputName = inputName.encode(core.SYS_ENCODING) except: pass results = processTorrent(dirName, inputName, subsection, inputHash, inputID, clientAgent) if results[0] != 0: logger.error("A problem was reported when trying to perform a manual run for %s:%s." % ( section, subsection)) result = results if result[0] == 0: logger.info("The %s script completed successfully." % (args[0])) else: logger.error("A problem was reported in the %s script." % (args[0])) del core.MYAPP return result[0]
def main(args): # Initialize the config core.initialize() # clientAgent for Torrents client_agent = core.TORRENT_CLIENTAGENT logger.info('#########################################################') logger.info('## ..::[{0}]::.. ##'.format(os.path.basename(__file__))) logger.info('#########################################################') # debug command line options logger.debug('Options passed into TorrentToMedia: {0}'.format(args)) # Post-Processing Result result = ProcessResult( message='', status_code=0, ) try: input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args) except Exception: logger.error('There was a problem loading variables') return -1 if input_directory and input_name and input_hash and input_id: result = process_torrent(input_directory, input_name, input_category, input_hash, input_id, client_agent) else: # Perform Manual Post-Processing logger.warning('Invalid number of arguments received from client, Switching to manual run mode ...') for section, subsections in core.SECTIONS.items(): for subsection in subsections: if not core.CFG[section][subsection].isenabled(): continue for dir_name in core.get_dirs(section, subsection, link='hard'): logger.info('Starting manual run for {0}:{1} - Folder:{2}'.format (section, subsection, dir_name)) logger.info('Checking database for download info for {0} ...'.format (os.path.basename(dir_name))) core.DOWNLOADINFO = core.get_download_info(os.path.basename(dir_name), 0) if core.DOWNLOADINFO: client_agent = text_type(core.DOWNLOADINFO[0].get('client_agent', 'manual')) input_hash = text_type(core.DOWNLOADINFO[0].get('input_hash', '')) input_id = text_type(core.DOWNLOADINFO[0].get('input_id', '')) logger.info('Found download info for {0}, ' 'setting variables now ...'.format(os.path.basename(dir_name))) else: logger.info('Unable to locate download info for {0}, ' 'continuing to try and process this release ...'.format (os.path.basename(dir_name))) client_agent = 'manual' input_hash = '' input_id = '' if client_agent.lower() not in core.TORRENT_CLIENTS: continue try: dir_name = dir_name.encode(core.SYS_ENCODING) except UnicodeError: pass input_name = os.path.basename(dir_name) try: input_name = input_name.encode(core.SYS_ENCODING) except UnicodeError: pass results = process_torrent(dir_name, input_name, subsection, input_hash or None, input_id or None, client_agent) if results[0] != 0: logger.error('A problem was reported when trying to perform a manual run for {0}:{1}.'.format (section, subsection)) result = results if result.status_code == 0: logger.info('The {0} script completed successfully.'.format(args[0])) else: logger.error('A problem was reported in the {0} script.'.format(args[0])) del core.MYAPP return result.status_code
from core import BeamR, SweepDiffractionExecutorR, KerrExecutorR, Propagator, VisualizerR, parse_args # parse args from command line args = parse_args() # create object of 3D axisymmetric beam beam = BeamR(medium='LiF', p_0_to_p_vortex=5, m=1, M=1, lmbda=1800*10**-9, r_0=100*10**-6, radii_in_grid=70, n_r=4096) # create visualizer object visualizer = VisualizerR(beam=beam, remaining_central_part_coeff_field=0.05, remaining_central_part_coeff_spectrum=0.05) # create propagator object propagator = Propagator(args=args, beam=beam, diffraction=SweepDiffractionExecutorR(beam=beam), kerr_effect=KerrExecutorR(beam=beam), n_z=1000, dz_0=beam.z_diff / 1000, const_dz=True, print_current_state_every=1, plot_beam_every=5, max_intensity_to_stop=5 * 10**17,
roman += roman_map[i] numb -= i return roman def is_untitled(title): return title == None or title[0] == "Untitled" def title_files(files, verbose = False, confirm = False): ''' changes titles of given mp3 files ''' for f in files: a = EasyID3(f) if is_untitled(a["title"]): m = re.search('^(\d+)(/\d*)?$', a["tracknumber"][0]) if m: tn = int(m.group(1)) if(confirm or core.confirm("change title for %s?" % f)): a["title"] = to_roman(tn) if(verbose): print ("%s => %s" % (f, a["title"])) a.save() def main(target, recursive = False, verbose = False, confirm = False): title_files(core.list_files(target, core.mp3_filter, recursive), verbose, confirm) if __name__ == '__main__': args = core.parse_args(sys.argv) if(args != None): main(args['target'], args['recursive'], args['verbose'], args['confirm'])