def main() -> None: args = get_args() if args._to is not None: result = to_morse(args._to) print(result) if args.sound: morse_code_sound(result) else: print(from_morse(args._from)) if args.sound: morse_code_sound(args._from)
def main(): args = get_args() if not args.save and not args.new_key: print 'Either --save or --new-key required' return connection_string = 'mongodb://%s' % args.uri # instance of Collection db = MongoClient(connection_string).get_default_database().services service = Service(args.name, db) if args.save: print service.save() elif args.new_key: print service.new_api_key()
def main(): args = get_args() phaser = Phase( args.input_file, n_tracks=args.n_tracks, gap=args.gap, initial_gap=args.initial_gap, repeat_count=args.repeat_count, end_align=args.end_align, start_pad_duration=args.start_pad_duration, end_pad_duration=args.end_pad_duration, temp_folder=args.temp_folder, output_folder=args.output_folder, fade=args.fade, quietest=args.quietest, gain=args.gain, trim_start=args.trim_start, trim_end=args.trim_end, solo_track_number=args.solo_track_number, solo_repetition_number=args.solo_repetition_number, )
CONF = get_config(CONFIGFILE) if CONF["Api"] == "Coapcmd": from tradfricoap.coapcmd_api import set_coapcmd set_coapcmd("{}/bin/coapcmd".format( os.path.dirname(os.path.realpath(__file__)))) except ImportError: _globalError = "Module 'tradfricoap' not found" if __name__ == "__main__": from cli import get_args # from tradfri.config import host_config args = get_args() if args.command == "api": config = host_config(CONFIGFILE) config.set_config_item("api", args.API) config.save() exit() try: from tradfricoap.device import get_devices, get_device from tradfricoap.gateway import create_ident from tradfricoap.errors import HandshakeError except ImportError: print("Module 'tradfricoap' not found!") exit()
#!/usr/bin/env python3 import cli args = cli.get_args() import logging import logging.config from os import popen, path import yaml def __log_setup(debug): log_cfg = path.join(path.dirname(__file__), 'logging.yaml') try: cfg = None with open(log_cfg, 'r') as f: cfg = yaml.load(f) if cfg: logging.config.dictConfig(cfg) if debug: logging.root.setLevel(logging.DEBUG) except IOError as e: log = logging.getLogger(__name__) log.warn('Could not load logging configuration from "{}"'.format(log_cfg)) log.warn('Using default configuration ...') log.warn(e) __log_setup(args.debug) log = logging.getLogger(__name__) import config_parser from subprocess import check_call, CalledProcessError
from cli import get_args from mode import LoadSession, GetSession #from mode import GetSession arguments = get_args() if arguments.mode == 'load': ld_session = LoadSession(arguments.db_path, arguments.show_errors) ld_session.create_db() total_time, total_size = ld_session.run(arguments.url, arguments.depth) print( f'ok, execution time: {total_time}s, memory usage: {total_size//10**6} Mb' ) elif arguments.mode == 'get': get_session = GetSession(arguments.db_path, arguments.url, arguments.n, arguments.html_path) get_session.show_pages()
def main(): print(logo) # Get args args = cli.get_args() # Load config config = {} with open(args.o) as f: config = json.load(f) if args.lossless: config['download']['lossless_only'] = True # Override loaded config with CLI options if possible if args.p is not None: cli.rec_update(config, cli.parse_config_overrides(args.p)) # Create a new API object api = TidalApi(config['tidal']['session'], config['tidal']['country_code']) # Authentication if args.urls[0] == 'auth': print('AUTHENTICATION: Enter your Tidal username and password:\n') uname = input('Username: '******'Password: '******'Attempting authentication...') auth = TidalApi.login(uname, pswd, config['tidal']['auth_token']) config['tidal']['session'] = auth['sessionId'] config['tidal']['country_code'] = auth['countryCode'] with open(args.o, 'w') as f: json.dump(config, f, indent='\t') print('Success!') exit() # Check if we need to authenticate if config['tidal']['session'] == '': print('Authentication required. Run again with `auth`.') exit() # Parse options media_to_download = cli.parse_media_option(args.urls) # Create a media downloader md = MediaDownloader(api, config['download'], Tagger(config['tagging'])) cm = 0 for mt in media_to_download: cm += 1 id = mt['id'] tracks = [] # Single track if mt['type'] == 't': print('<<< Getting track info... >>>', end='\r') track = api.get_track(id) # Download and tag file print('<<< Downloading single track... >>>') _, filepath = md.download_media(track, config['tidal']['quality']) print('=== 1/1 complete (100% done) ===\n') # Collection elif mt['type'] == 'p' or mt['type'] == 'a' or mt['type'] == 'f': typename = 'playlist' if mt['type'] == 'p' else 'album' print('<<< Getting {0} info... >>>'.format(typename), end='\r') media_info = None if mt['type'] == 'p': # Make sure only tracks are in playlist items playlistItems = api.get_playlist_items(id)['items'] for item in playlistItems: if item['type'] == 'track': tracks.append(item['item']) else: try: media_info = api.get_album(id) except: print('api error, skipping\n', end='\r') continue tracks = api.get_album_tracks(id)['items'] total = len(tracks) print('<<< Downloading {0}: {1} track(s) in total >>>'.format( typename, total)) cur = 0 for track in tracks: md.download_media(track, config['tidal']['quality'], media_info) cur += 1 print('=== {0}/{1} complete ({2:.0f}% done) ===\n'.format( cur, total, (cur / total) * 100)) else: print('Unknown media type - ' + mt['type']) print('> Download queue: {0}/{1} items complete ({2:.0f}% done) <\n'. format(cm, len(media_to_download), (cm / len(media_to_download)) * 100)) print('> All downloads completed. <')
def main(): cli_args = cli.get_args() _create_graph(cli_args[0], languages.get(cli_args[1]), cli_args[2])
end = clock() total = end - START print("Completion time: {0} seconds.".format(total)) # List of properties. # See: http://goo.gl/fjTEpW # for all properties. vm_properties = [ "name", "config.uuid", "config.hardware.numCPU", "config.hardware.memoryMB", "guest.guestState", "config.guestFullName", "config.guestId", "config.version", "config.firmware", "config.hardware.numCoresPerSocket", "summary.guest.ipAddress" ] args = cli.get_args() service_instance = None try: service_instance = connect.SmartConnectNoSSL(host=args.host, user=args.user, pwd=args.password, port=int(args.port)) atexit.register(connect.Disconnect, service_instance) atexit.register(endit) except IOError as e: pass if not service_instance: raise SystemExit("Unable to connect to host with supplied info.") root_folder = service_instance.content.rootFolder