def main(): parser = argparse.ArgumentParser( description="Play any radio around the globe right from the CLI ", prog="radio-active", ) parser.add_argument("--version", action="version", version="%(prog)s 1.0") parser.add_argument( "--station", action="store", dest="station_name", help="Specify a station name", ) parser.add_argument( "--uuid", action="store", dest="station_uuid", help="Specify a station UUID", ) parser.add_argument( "--log-level", action="store", default="info", dest="log_level", help="Specify log level", ) args = parser.parse_args() station_name = args.station_name station_uuid = args.station_uuid log_level = args.log_level if log_level in ["info", "error", "debug"]: log.level(log_level) else: log.level("info") log.warning( "Correct log levels are: error,warning,info(default),debug") if station_name is None and station_uuid is None: log.critical( "Need a station name or UUID to play the radio, see help") sys.exit(0) # log.debug("Station name: " + station_name) handler = Handler() target_station = None # uuid gets first preference if station_uuid is not None: handler.play_by_station_uuid(station_uuid) if station_uuid is None and station_name is not None: handler.play_by_station_name(station_name) global player player = Player(handler.target_station["url"]) signal.pause()
def myMain(): x=input('Enter x:') if argv[1] == 'zen': log.level('info') log.d('debug') log.i('info x={}'.format(x)) log.w('warn') log.e('error') log.c('critical') else: if argv[1] == 'basic': # see Python Docs logging.html 16.6.7. LogRecord attributes logging.basicConfig(style='{',format="{asctime:s}:{filename:s}:{lineno:d}:{msg:s}",level='DEBUG') logging.debug('our debug message x={}'.format(x)) logging.warn('our warn message x={}'.format(x)) else: print("If we don't want to type logging.debug() etc, we have to create our own logger lg=logging.getLogger({})".format(__name__)) lg=logging.getLogger(__name__) if argv[1]=='easy': logging.basicConfig(level='INFO') else: lg.setLevel('WARN') # optional: defaults to all levels lg.addHandler(logging.StreamHandler()) lg.handlers[0].setFormatter(logging.Formatter(style='{',fmt="{filename:s}:{funcName:s}():{lineno:d}:{msg:s}")) lg.debug('our debug mesage') lg.info('our info here')
def main(): global args args = get_args() if not args.debug: log.level(logging.INFO) else: log.level(logging.DEBUG) if args.user_name: download_directory = os.path.expanduser(args.directory + '/' + args.user_name) elif args.gallery: download_directory = os.path.expanduser(args.directory + '/gallery/' + args.gallery) # make sure the download directory exists, then change to it if not os.path.exists(download_directory): os.makedirs(download_directory) os.chdir(download_directory) if args.user_name: action_download_submitted_images() elif args.gallery: action_download_imgur_gallery()
def main(): # Argument parser parser = argparse.ArgumentParser( prog="parameters_fuzzer", description="ROS 2 automatic parameters fuzzer" ) parser.add_argument( "node_name", help='(i.e. "minimal_subscriber")', ) parser.add_argument( "package_name", help='(i.e. "mypackage")', ) parser.add_argument( "executable_name", help='(i.e. "listener")', ) parser.add_argument( "-v", "--verbose", help="increase output verbosity", action="store_true" ) args = parser.parse_args() node_name = args.node_name package_name = args.package_name executable_name = args.executable_name is_verbose = args.verbose # Change verbosity logging.level(DEBUG if is_verbose else INFO) # 1. Get parameters parameters = get_parameters( node_name=node_name, package_name=package_name, executable_name=executable_name ) print(parameters)
def main(): parser = argparse.ArgumentParser(description="Bridge the gap between IM platforms") parser.add_argument('-l', '--loglevel', dest='loglevel', default="info", help='Set log level(Default: info)') args = parser.parse_args() log.level(args.loglevel) m = Manager() s1 = SamplePlatform(m, "p1") s2 = SamplePlatform(m, "p2") m.add_im(s1) m.add_im(s2) m.run()
def usage() -> str: parser = argparse.ArgumentParser(prog="ros2_fuzzer", description="ROS 2 automatic fuzzer") parser.add_argument( "--path", help="Path where the fuzz.yaml file is located", ) parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true") args = parser.parse_args() path = args.path if args.path else os.getcwd() logging.level(DEBUG if args.verbose else INFO) return path
def usage(): parser = argparse.ArgumentParser( prog="auto_detector", description="Automatic C++ ROS 2 components finder") parser.add_argument( "--path", help= "path to search for ROS artifacts (default = the working directory)", ) parser.add_argument("-f", "--overwrite", help="forces overwrite", action="store_true") parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true") args = parser.parse_args() path = args.path if args.path else os.getcwd() logging.level(DEBUG if args.verbose else INFO) return path, args.overwrite
from utils import csv2json, download_file, fetch_data_package from zenlog import log CONFIG_FILE = "settings.conf" OUTPUT_DIR = "_output" REPO_DIR = "repos" datasets_dir = "datasets" files_dir = "download" THEMES_DIR = "themes" # init global vars env = None packages = [] # set logging level log.level('info') def local_and_remote_are_at_same_commit(repo, remote): local_commit = repo.commit() remote_commit = remote.fetch()[0].commit return local_commit.hexsha == remote_commit.hexsha def create_index_page(packages, output_dir): '''Generates the index page with the list of available packages. Accepts a list of pkg_info dicts, which are generated with the process_datapackage function.''' template = env.get_template("list.html") target = "index.html" context = {
# from utils import download_file from zenlog import log CONFIG_FILE = "settings.conf" OUTPUT_DIR = "_output" REPO_DIR = "repos" datasets_dir = "datasets" files_dir = "download" THEMES_DIR = "themes" # init global vars env = None packages = [] # set logging level log.level('info') global_context = {"welcome_text": markdown.markdown(codecs.open("content/welcome_text.md", 'r', 'utf-8').read(), output_format="html5", encoding="UTF-8")} def local_and_remote_are_at_same_commit(repo, remote): local_commit = repo.commit() remote_commit = remote.fetch()[0].commit return local_commit.hexsha == remote_commit.hexsha def create_index_page(packages, output_dir): '''Generates the index page with the list of available packages. Accepts a list of pkg_info dicts, which are generated with the process_datapackage function.''' template = env.get_template("list.html")