def run(): print("nzbverify version %s, Copyright (C) 2014 %s" % (__version__, __author__)) config = None log_file = None log_level = logging.INFO # Parse command line options opts, args = getopt.getopt(sys.argv[1:], 'c:l:n:h', ["config=", "log=", "level=", "help"]) for o, a in opts: if o in ("-h", "--help"): print(__help__) print_usage() sys.exit(0) elif o in ("-c", "--config"): config = a elif o in ("-l", "--log"): log_file = a elif o in ("-n", "--level"): try: log_level = int(a) except: log_level = 0 if log_level > 0: log_level = logging.DEBUG else: log_level = logging.INFO if log_file: logging.basicConfig( filename=log_file, level=log_level, format= "%(asctime)s [%(levelname)s] - [%(threadName)10s] - %(name)s - %(message)s" ) # Get the NZB if len(args) < 1: print_usage() sys.exit(0) nzb = args[0] # Load NNTP details from config files config = conf.get_config(config) if not config: print("Error: No config file found") sys.exit(0) if len(config) < 1: print("Error: Didn't find any servers") sys.exit(0) start = time.time() main(nzb, config) print("Verification took %s seconds" % (time.time() - start))
def run(): print "nzbverify version %s, Copyright (C) 2014 %s" % (__version__, __author__) config = None log_file = None log_level = logging.INFO # Parse command line options opts, args = getopt.getopt(sys.argv[1:], 'c:l:n:h', ["config=", "log=", "level=", "help"]) for o, a in opts: if o in ("-h", "--help"): print __help__ print_usage() sys.exit(0) elif o in ("-c", "--config"): config = a elif o in ("-l", "--log"): log_file = a elif o in ("-n", "--level"): try: log_level = int(n) except: log_level = 0 if log_level > 0: log_level = logging.DEBUG else: log_level = logging.INFO if log_file: logging.basicConfig(filename=log_file, level=log_level, format="%(asctime)s [%(levelname)s] - [%(threadName)10s] - %(name)s - %(message)s") # Get the NZB if len(args) < 1: print_usage() sys.exit(0) nzb = args[0] # Load NNTP details from config files config = conf.get_config(config) if not config: print "Error: No config file found" sys.exit(0) if len(config) < 1: print "Error: Didn't find any servers" sys.exit(0) start = time.time() main(nzb, config) print "Verification took %s seconds" % (time.time() - start)
def run(): print "%s version %s" % (__prog__, __version__) num_connections = DEFAULT_NUM_CONNECTIONS config = None max_bitrate = None do_verify = True nntp_kwargs = { 'host': None, 'port': nntplib.NNTP_PORT, 'user': None, 'password': None, 'use_ssl': None, 'timeout': 10, 'threads': DEFAULT_NUM_CONNECTIONS } # Parse command line options opts, args = getopt.getopt(sys.argv[1:], 's:u:P:n:c:b:qeph', [ "server=", "username="******"port=", "connections=", "config=", "ssl", "password", "verify", "bitrate=", "help"]) for o, a in opts: if o in ("-h", "--help"): print_usage() sys.exit(0) elif o in ("-s", "--server"): nntp_kwargs['host'] = a elif o in ("-u", "--username"): nntp_kwargs['user'] = a elif o in ("-p", "--password"): nntp_kwargs['password'] = getpass.getpass("Password: "******"-e", "--ssl"): nntp_kwargs['use_ssl'] = True elif o in ("-P", "--port"): try: nntp_kwargs['port'] = int(a) except: print "Error: invalid port '%s'" % a sys.exit(0) elif o in ("-n", "--connections"): try: nntp_kwargs['threads'] = int(a) except: print "Error: invalid number of connections '%s'" % a sys.exit(0) elif o in ("-c", "--config"): config = a elif o in ("-b", "--bitrate"): try: max_bitrate = float(a) except: print "Error: invalid bitrate: '%s'" % a sys.exit(0) elif o in ("-q", "--verify"): do_verify = False # Get the NZB if len(args) < 1: print_usage() sys.exit(0) nzb = args[0] # See if we need to load certain NNTP details from config files # A host is required config = conf.get_config(config, defaults=DEFAULT_CONFIG_PATHS) if not nntp_kwargs['host'] and not config: print "Error: no server details provided" sys.exit(0) if config: credentials = config.authenticators(nntp_kwargs.get('host')) if not credentials: if not config.hosts: print "Error: Could not determine server details" sys.exit(0) # Just use the first entry host, credentials = config.hosts.items()[0] nntp_kwargs['host'] = host if not nntp_kwargs['user'] and not nntp_kwargs['password']: nntp_kwargs['user'] = credentials[0] nntp_kwargs['password'] = credentials[2] main(nzb, nntp_kwargs, max_bitrate, do_verify)
def run(): print "nzbverify version %s, Copyright (C) 2012 %s" % (__version__, __author__) num_connections = DEFAULT_NUM_CONNECTIONS config = None nntp_kwargs = { 'host': None, 'port': nntplib.NNTP_PORT, 'user': None, 'password': None, 'use_ssl': None, 'timeout': 10 } # Parse command line options opts, args = getopt.getopt(sys.argv[1:], 's:u:P:n:c:eph', ["server=", "username="******"port=", "connections=", "config=", "ssl", "password", "help"]) for o, a in opts: if o in ("-h", "--help"): print __help__ print_usage() sys.exit(0) elif o in ("-s", "--server"): nntp_kwargs['host'] = a elif o in ("-u", "--username"): nntp_kwargs['user'] = a elif o in ("-p", "--password"): nntp_kwargs['password'] = getpass.getpass("Password: "******"-e", "--ssl"): nntp_kwargs['use_ssl'] = True elif o in ("-P", "--port"): try: nntp_kwargs['port'] = int(a) except: print "Error: invalid port '%s'" % a sys.exit(0) elif o in ("-n", "--connections"): try: num_connections = int(a) except: print "Error: invalid number of connections '%s'" % a sys.exit(0) elif o in ("-c", "--config"): config = a # Get the NZB if len(args) < 1: print_usage() sys.exit(0) nzb = args[0] # See if we need to load certain NNTP details from config files # A host is required config = conf.get_config(config) if not nntp_kwargs['host'] and not config: print "Error: no server details provided" sys.exit(0) if config: credentials = config.authenticators(nntp_kwargs.get('host')) if not credentials: if not config.hosts: print "Error: Could not determine server details" sys.exit(0) # Just use the first entry host, credentials = config.hosts.items()[0] nntp_kwargs['host'] = host if not nntp_kwargs['user'] and not nntp_kwargs['password']: nntp_kwargs['user'] = credentials[0] nntp_kwargs['password'] = credentials[2] start = time.time() main(nzb, num_connections, nntp_kwargs) print "Verification took %s seconds" % (time.time() - start)
def run(): print "nzbverify version %s, Copyright (C) 2012 %s" % (__version__, __author__) num_connections = DEFAULT_NUM_CONNECTIONS config = None nntp_kwargs = { 'host': None, 'port': nntplib.NNTP_PORT, 'user': None, 'password': None, 'use_ssl': None, 'timeout': 10 } # Parse command line options opts, args = getopt.getopt(sys.argv[1:], 's:u:P:n:c:p:eh', [ "server=", "username="******"port=", "connections=", "config=", "ssl", "password="******"help" ]) for o, a in opts: if o in ("-h", "--help"): print __help__ print_usage() sys.exit(0) elif o in ("-s", "--server"): nntp_kwargs['host'] = a elif o in ("-u", "--username"): nntp_kwargs['user'] = a elif o in ("-p", "--password"): nntp_kwargs['password'] = a elif o in ("-e", "--ssl"): nntp_kwargs['use_ssl'] = True elif o in ("-P", "--port"): try: nntp_kwargs['port'] = int(a) except: print "Error: invalid port '%s'" % a sys.exit(0) elif o in ("-n", "--connections"): try: num_connections = int(a) except: print "Error: invalid number of connections '%s'" % a sys.exit(0) elif o in ("-c", "--config"): config = a # Get the NZB if len(args) < 1: print_usage() sys.exit(0) nzb = args[0] # See if we need to load certain NNTP details from config files # A host is required config = conf.get_config(config) if not nntp_kwargs['host'] and not config: print "Error: no server details provided" sys.exit(0) if config: credentials = config.authenticators(nntp_kwargs.get('host')) if not credentials: if not config.hosts: print "Error: Could not determine server details" sys.exit(0) # Just use the first entry host, credentials = config.hosts.items()[0] nntp_kwargs['host'] = host if not nntp_kwargs['user'] and not nntp_kwargs['password']: nntp_kwargs['user'] = credentials[0] nntp_kwargs['password'] = credentials[2] start = time.time() main(nzb, num_connections, nntp_kwargs) print "Verification took %s seconds" % (time.time() - start)