예제 #1
0
def main():
    args = parser.parse_args()

    Fetcher =Fetch(args.url, args.threadNum, args.limit)
    Fetcher.start()

    PicCrawler = Crawler(args.threadNum, args.path, args.limit)
    PicCrawler.start()
예제 #2
0
파일: main.py 프로젝트: WiseDoge/crawler
def main():
    args = parser.parse_args()
    if not congifLogger(args.logFile, args.logLevel):
        print ('\nPermission denied: %s') % args.logFile
        print ('Please make sure you have the permission to save the log file!\n')
    elif args.testSelf:
        Crawler(args).selfTesting(args)
    else:
        crawler = Crawler(args)
        printProgress = PrintProgress(crawler)
        printProgress.start()
        crawler.start()
        printProgress.printSpendingTime()
예제 #3
0
파일: cli.py 프로젝트: daltonmatos/codepad
  def __init__(self):
    opts = parser.parse_args()

    paste_type = opts.lang or (opts.code and opts.code.split('.')[-1])
    self.lang = file_types.get(paste_type, self.DEFAULT_TYPE)

    self.code = opts.code
    if opts.code is self.STDIN: #If we discover that we will need stdin, change it.
      self.code = sys.stdin
    else:
      # Check if the file exists
      if self.code and not os.path.exists(str(self.code)):
        raise Exception("{0} does not exist".format(self.code))

    self.runit = opts.run
    self.private = opts.private
예제 #4
0
def main():
    args = parser.parse_args()
    if not configLogger(args.logFile, args.logLevel):
        print '\nPermission denied :%s' % args.logFile
        print 'Please make sure you have the permission to save yhe log file\n'
    elif args.testSelf:
    	Crawler(args).selfTesting()
    else:
        log = logging.getLogger('Main')
        log.debug('F**k')
        #print 'Hello World'
        #log = logging.getLogger('Main')
        #log.error('F**k tourself')
        crawler = Crawler(args)
        printProgress = PrintProgress(crawler)
        printProgress.start()
        crawler.start()
        printProgress.printSpeedingTime()
예제 #5
0
def main(argv = sys.argv):
    # Aplicación
    
    from commands import COMMANDS
    from options import parser
    
    options = parser.parse_args()
    setup_logging(options)
    try:
        return runcommand(options.command[0], options, command_dict=COMMANDS)
    except errors.NoSuchCommand as e:
        print e
    except errors.CommandArgumentError as e:
        print "Command Argument Error: %s" % e
    except Exception as e:
        if options.traceback:
            from traceback import format_exc
            print type(e), e
            print format_exc()
    return -1
예제 #6
0
def main():
    args = parser.parse_args()
    update_tld_names()
    # Initilize the unvisited_urls.
    unvisited_url = deque()
    with io.open(args.domain_seeds, 'r+') as fp:
        urlList = fp.readlines()
        for url in urlList:
            if len(unvisited_url) < args.max_domain_seeds:
                unvisited_url.append(url)
        print 'We have got %d domain feeds.' % len(unvisited_url)

    if not config_logger(args.logFile, args.logLevel):
        print '\nPermission denied: %s' % args.logFile
        print 'Please make sure you have the permission to save the log file!\n'
    else:
        crawler = Crawler(args)
        print_progress = PrintProgress(crawler)
        print_progress.start()
        while len(unvisited_url) > 0:
            url = unvisited_url.popleft()
            crawler.crawl(url)
        print_progress.print_spending_time()
예제 #7
0
def main():
    args = parser.parse_args()
    argPath = args._argPath
    list_cf2(argPath)
예제 #8
0
    test_loss /= len(test_loader.dataset)
    print('Test set: Average loss: {:.4f}'.format(test_loss))
    utils.save_image(data.data,
                     'origin_pictures.png',
                     normalize=True,
                     scale_each=False)
    utils.save_image(output.data,
                     'reconstruct_pictures.png',
                     normalize=True,
                     scale_each=False)


if __name__ == '__main__':
    start_time = datetime.datetime.now().replace(microsecond=0)
    print('[Start at %s]' % start_time)
    args = parser.parse_args()
    use_cuda = not args.no_cuda and torch.cuda.is_available()
    args.use_cuda = use_cuda
    args.device = torch.device("cuda" if use_cuda else "cpu")

    train_loader, test_loader = get_dataloaders(args)
    model = get_model(args)
    optimizer = get_optimizer(args, model)

    print('\n--- Training ---')
    for epoch in range(1, args.epochs + 1):
        train(args, model, optimizer, train_loader, epoch)
        test(args, model, test_loader)
        current_time = datetime.datetime.now().replace(microsecond=0)
        print('Time Interval:', current_time - start_time, '\n')
예제 #9
0
from model.UNetAttn import UNetNoAttn
from data.CAT2000 import CAT2000
from interpretability.ig_saliency import integrated_gradients
from options import parser
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

# saved_model_path = "CMPUT566-main/code/comparison/mse_attn/model-epoch=196-val_acc=390.18.ckpt"
# saved_model_path = "CMPUT566-main/code/comparison/mse_attn/cc_attn-epoch=196-val_acc=395.79.ckpt"
saved_model_path_1 = "CMPUT566-main/code/comparison/mse_attn/mse_attn-epoch=196-val_acc=390.18.ckpt"
saved_model_path_2 = "CMPUT566-main/code/comparison/mse_attn/mse_noattn-epoch=194-val_acc=397.98.ckpt"
# saved_model_path = "CMPUT566-main/code/comparison/mse_attn/mse_noattn-epoch=194-val_acc=397.98.ckpt"

parser = UNetAttn.add_model_specific_args(parser)
args = parser.parse_args(args=[])
# change this to use other datasets
data_module = CAT2000(args)

# need to modify UnetAttn.py: custom_forward() to disable attn
model_1 = UNetAttn()
model_1 = model_1.load_from_checkpoint(saved_model_path_1)

model_2 = UNetNoAttn()
model_2 = model_2.load_from_checkpoint(saved_model_path_2)

print("done")

# index can be 0 - 1999
for i in range(100):
    index = i
예제 #10
0
def main():
    if os.name == 'nt':
        import logging
        logging.warning(
            'Windows is not currently supported. Many of the features in the Kubos-sdk will most likely not work correctly or at all on computers running Windows'
        )

    parser = argparse.ArgumentParser(
        formatter_class=argparse.RawTextHelpFormatter,
        description='kubos - the SDK for working with the KubOS RTOS\n' +
        'For more detailed help on each subcommand, run: kubos <subcommand> --help'
    )
    subparser = parser.add_subparsers(dest='subcommand_name',
                                      metavar='<subcommand>')

    def add_parser(name, module_name, description, help=None):
        if help is None:
            help = description

        def onParserAdded(parser):
            import importlib
            module = importlib.import_module('.' + module_name, 'kubos')
            module.addOptions(parser)
            parser.set_defaults(command=module.execCommand)

        subparser.add_parser_async(
            name,
            description=description,
            help=help,
            formatter_class=argparse.RawTextHelpFormatter,
            callback=onParserAdded)

    add_parser('build',
               'build',
               'Build the current project',
               help='Build the project in the current directory')
    add_parser('clean',
               'clean',
               'Remove files created by kubos builds',
               help='Remove files generated during the build')
    add_parser('config',
               'config',
               'Display the target configuration info',
               help='Display the target configuration info')
    add_parser('debug',
               'debug',
               'Debug the current module',
               help='Flash and launch the debugger for the current module')
    add_parser(
        'flash',
        'flash',
        'Flash the target device',
        help='Flash and start the built executable on the current target')
    add_parser('init',
               'init',
               'Initialize a new KubOS project',
               help='Create a new module')
    add_parser(
        'licenses',
        'licenses',
        'Print licenses for dependencies',
        help='List the licenses of the current module and its dependencies')
    add_parser(
        'link',
        'link',
        'Symlink a module',
        help='Flash and start the built executable on the current target')
    add_parser(
        'list',
        'list',
        'List module dependencies',
        help=
        'List the dependencies of the current module, or the inherited targets of the current target'
    )
    add_parser('remove',
               'remove',
               'remove a symlinked module',
               help='Remove a symlinked module')
    add_parser('search',
               'search',
               'Search for modules and targets',
               help='Search for published modules and targets')
    add_parser(
        'shrinkwrap',
        'shrinkwrap',
        'Create a yotta-shrinkwrap.json file to freeze dependency versions',
        help='free dependency versions')
    add_parser('target',
               'target',
               'Set the target device',
               help='Set or display the current target device')
    add_parser(
        'test',
        'test',
        'Run the tests for the current module on the current target. Requires target support for cross-compiling targets',
        help='Run the tests for the current module or target')
    add_parser('update',
               'update',
               'Pull the latest kubos-sdk container',
               help='Pull latest kubos-sdk docker container')
    add_parser('version',
               'version',
               'Show the current kubos-sdk version',
               help='Display version information')

    short_commands = {
        'up': subparser.choices['update'],
        'ln': subparser.choices['link'],
        'v': subparser.choices['version'],
        'ls': subparser.choices['list'],
        'rm': subparser.choices['remove'],
        'unlink': subparser.choices['remove'],
        'unlink-target': subparser.choices['remove'],
        'lics': subparser.choices['licenses'],
    }
    subparser.choices.update(short_commands)

    split_args = splitList(sys.argv, '--')
    following_args = reduce(lambda x, y: x + ['--'] + y, split_args[1:],
                            [])[1:]

    args = parser.parse_args(split_args[0][1:])

    if 'command' not in args:
        parser.print_usage()
        sys.exit(0)

    try:
        status = args.command(args, following_args)
    except KeyboardInterrupt:
        logging.warning('interrupted')
        status = -1

        sys.exit(status or 0)
예제 #11
0
#!python3
import sys
from options import parser
from download_tracks import download_tracks

if __name__ == '__main__':
    args = parser.parse_args(sys.argv[1:])

    download_tracks(args.username, args.limit, args.output_folder)
예제 #12
0
def main():
    if os.name == 'nt':
        logging.warning('Windows is not currently supported. Many of the features in the Kubos-sdk will most likely not work correctly or at all on computers running Windows')

    parser = argparse.ArgumentParser(
        formatter_class=argparse.RawTextHelpFormatter,
        description='kubos - the SDK for working with the KubOS RTOS\n'+
        'For more detailed help on each subcommand, run: kubos <subcommand> --help'
    )

    config = sdk_config.load_config()
    subparser = parser.add_subparsers(dest='subcommand_name', metavar='<subcommand>')

    add_command = functools.partial(command.add_command, config, subparser)
    add_command('build', 'build', 'Build the current project', help='Build the project in the current directory')
    add_command('clean', 'clean', 'Remove files created by kubos builds', help='Remove files generated during the build')
    add_command('config', 'config', 'Display the target configuration info', help='Display the target configuration info')
    add_command('debug', 'debug', 'Debug the current module', help='Flash and launch the debugger for the current module')
    add_command('flash', 'flash', 'Flash the target device', help='Flash and start the built executable on the current target')
    add_command('init', 'init', 'Initialize a new KubOS project', help='Create a new module')
    add_command('licenses', 'licenses', 'Print licenses for dependencies', help='List the licenses of the current module and its dependencies')
    add_command('link', 'link', 'Symlink a module', help='Flash and start the built executable on the current target')
    add_command('link-target', 'link_target', 'Symlink a target', help='Symlink a target into a kubos project')
    add_command('list', 'list', 'List module dependencies', help='List the dependencies of the current module, or the inherited targets of the current target')
    add_command('remove', 'remove', 'remove a symlinked module', help='Remove a symlinked module')
    add_command('search', 'search', 'Search for modules and targets', help='Search for published modules and targets')
    add_command('server', 'server', 'Kubos debug GDB server', help='Interact with the Kubos GDB server')
    add_command('shrinkwrap', 'shrinkwrap', 'Create a yotta-shrinkwrap.json file to freeze dependency versions', help='free dependency versions')
    add_command('target', 'target', 'Set the target device', help='Set or display the current target device')
    add_command('test', 'test', 'Run the tests for the current module on the current target. Requires target support for cross-compiling targets', help='Run the tests for the current module or target')
    add_command('update', 'update', 'Pull the latest kubos-sdk container', help='Pull latest kubos-sdk docker container')
    add_command('version', 'version', 'Show the current kubos-sdk version', help='Display version information')

    short_commands = {
                'up':subparser.choices['update'],
                'ln':subparser.choices['link'],
                 'v':subparser.choices['version'],
                'ls':subparser.choices['list'],
                'rm':subparser.choices['remove'],
            'unlink':subparser.choices['remove'],
     'unlink-target':subparser.choices['remove'],
              'lics':subparser.choices['licenses'],
    }
    subparser.choices.update(short_commands)

    split_args = splitList(sys.argv, '--')
    following_args = reduce(lambda x,y: x + ['--'] + y, split_args[1:], [])[1:]

    args = parser.parse_args(split_args[0][1:])

    if 'command' not in args:
        parser.print_usage()
        sys.exit(0)

    try:
        status = args.command(args, following_args)
    except KeyboardInterrupt:
        logging.warning('interrupted')
        status = -1

        sys.exit(status or 0)