Example #1
0
 def crawl(self, resume=False):
     log.init(log_file=self.log_file, log_level=self.log_level,
              log_format=self.log_format)
     log.info('ItemScraper %s with %s crawling started' %
              (self.name, self.crawling_order))
     log.info('Depth limit: %d' % self.depth_limit)
     if self.download_delay > 0:
         log.info('Download delay: %d' % self.download_delay)
         if self.randomize_download_delay:
             log.info('Randomization of download delay enabled')
     self._init_db(resume)
     self._init_state(resume)
     try:
         while not self._pending_urls.empty():
             (depth, url) = self._pending_urls.get()
             (page_data, code) = self._get_page_data_retry(url)
             log.debug('Crawled (%d) <GET %s>' % (code, url))
             if page_data:
                 self._process_page_and_extract_links(page_data, depth)
             # Append url to self._processed_urls
             self._processed_urls.append(url)
             self._try_to_save_items()
     except KeyboardInterrupt:
         pass
     self._finalize()
def new_game():
    """
    Starts a new game, with a default player on level 1 of the dungeon.
    Returns the player object.
    """
    # Must initialize the log before we do anything that might emit a message.
    log.init()

    fighter_component = Fighter(hp=100, defense=1, power=2, xp=0, death_function=player_death)
    player = Object(algebra.Location(0, 0), '@', 'player', libtcod.white, blocks=True, fighter=fighter_component)
    player.inventory = []
    player.level = 1
    player.game_state = 'playing'
    # True if there's a (hostile) fighter in FOV
    player.endangered = False

    obj = miscellany.dagger()
    player.inventory.append(obj)
    actions.equip(player, obj.equipment, False)
    obj.always_visible = True

    cartographer.make_map(player, 1)
    renderer.clear_console()
    renderer.update_camera(player)

    log.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)
    log.message('Press ? or F1 for help.')

    return player
Example #3
0
def app_and_logging(qapp):
    """Initialize a QApplication and logging.

    This ensures that a QApplication is created and used by all tests.
    """
    from log import init
    init()
Example #4
0
def start(server_address: str='localhost'):
    # Init log
    log.init('/var/log/khome.log' if server_address == 'localhost' else '')
    log.info('Starting with a Server on %s.' % server_address)
    # Configuration
    try:
        # Storage
        inv.storage_init(server_address)
        # Load - Actors to Inventory
        actor_configs = inv.load_actors_start()
        for aid in actor_configs:
            inv.register_actor(create_actor(actor_configs[aid], aid))
        inv.load_actors_stop()
        log.info('Configuration has been loaded from Storage.')
    except StorageError as err:
        log.error('Cannot init Storage %s.' % err)
    # Bus and Scheduler
    try:
        # Bus
        bus.init(server_address, on_connect_to_bus, on_message_from_bus)
        log.info('Connected to Bus.')
        # Scheduler
        sch.init_timer()
        log.info('Scheduler has been started.')
        # Start
        bus.listen()
    except (ConnectionRefusedError, TimeoutError) as err:
        log.error('Cannot connect to Bus (%s).' % err)
        log.info('KHome manager stops with failure.')
Example #5
0
def main(feet=None):
    log.init()

    meters = utils.feet_to_meters(feet)

    if meters is not None:
        click.echo(meters)
    def __init__( self, capture, log, settings ):
        # port="",filters="", hsv=False, original=True, in_file="", out_file="", display=True
        self.limits = {}
        # Pass the log object
        self.log = log
        log.init( "initializing saber_track Tracker" )
        self.settings = settings
        # If the port tag is True, set the
        if settings["port"] != "":
            logging.basicConfig( level=logging.DEBUG )
            NetworkTable.setIPAddress( settings["port"] )
            NetworkTable.setClientMode( )
            NetworkTable.initialize( )
            self.smt_dash = NetworkTable.getTable( "SmartDashboard" )

        # initialize the filters. If the filter is the default: "", it will not create trackbars for it.
        self.init_filters( settings["filters"] )

        # Deal with inputs and outputs
        self.settings["out_file"] = str( self.settings["out_file"] ) # set the file that will be written on saved

        if settings["in_file"] != "":
            self.log.init( "Reading trackfile: " + settings["in_file"] + ".json" )
            fs = open( name + ".json", "r" ) # open the file under a .json extention
            data = json.loads( fs.read() )
            self.limits.update( data )
            fs.close( )


        # Localize the caputure object
        self.capture = capture
        # if there are any color limits (Upper and Lower hsv values to track) make the tracking code runs
        self.track = len( self.limits ) > 0

        self.log.info( "Tracking: " + str(self.track) )
Example #7
0
 def __init__(self):
     self.conn = conn_mongo.conn_mongo(DB, DB_HOST)
     self.product = self.conn.get_product_col('product')
     self.conn.index_unique(self.product, 'bah')
     self.logger_category = log.init('bhphotovideo_category', 'bhphotovideo_category.txt')
     self.logger_list = log.init('bhphotovideo_list', 'bhphotovideo_list.txt')
     self.logger_product = log.init('bhphotovideo_product', 'bhphotovideo_product.txt')
Example #8
0
 def __init__(self):
     self.siteurl = 'http://www.bestbuy.com'
     self.conn = conn_mongo.conn_mongo(DB, MONGODB_HOST)
     self.product = self.conn.get_product_col('product')
     self.conn.index_unique(self.product, 'sku')
     self.logger_category = log.init('bestbuy_category', 'bestbuy_category.txt')
     self.logger_list = log.init('bestbuy_list', 'bestbuy_list.txt')
     self.logger_product = log.init('bestbuy_product', 'bestbuy_product.txt')
Example #9
0
    def __init__(self, parser, args):
        self.hosts, self.groups = args.H, args.g
        if len(self.hosts) == 0 and len(self.groups) == 0:
            parser.error('at least one host or group should be specified')

        self.active_hosts = set()
        self.failed_hosts = set()
        self.all_failed_hosts = set()
        log.init(self.log, args.C)
Example #10
0
def main():
    parser = createParser()
    args = parser.parse_args()

    log.init("root", args.verbosity, args.log_file)
    logger = logging.getLogger("root")
    logger.info("Python photo gallery started!")
    logger.debug("Args: %s", str(args))

    controller = ctrl.Controller(args)
    controller.main()
Example #11
0
def run():
    args = config.manager.early_parse(sys.argv[1:])
    log.init(args.debug)

    if args.config:
        config.manager.load_config(args.config)

    config.manager.augment_config()

    plumbing = Plumbing()
    sys.exit(plumbing.run())
Example #12
0
def execute(args, command_args):
  """Execute IDA Pro as a subprocess, passing this file in as a batch-mode
  script for IDA to run. This forwards along arguments passed to `remill-lift`
  down into the IDA script. `command_args` contains unparsed arguments passed
  to `remill-lift`. This script may handle extra arguments."""

  ida_disass_path = os.path.abspath(__file__)
  ida_dir = os.path.dirname(ida_disass_path)

  env = {}
  env["IDALOG"] = os.devnull
  env["TVHEADLESS"] = "1"
  env["HOME"] = os.path.expanduser('~')
  env["IDA_PATH"] = os.path.dirname(args.disassembler)
  env["PYTHONPATH"] = os.path.dirname(ida_dir)

  script_cmd = []
  script_cmd.append(ida_disass_path.rstrip("c"))  # (This) script file name.
  script_cmd.append("--output")
  script_cmd.append(args.output)
  script_cmd.append("--log_file")
  script_cmd.append(args.log_file)
  script_cmd.append("--log_level")
  script_cmd.append(str(args.log_level))
  script_cmd.append("--arch")
  script_cmd.append(args.arch)
  script_cmd.extend(command_args)  # Extra, script-specific arguments.

  cmd = []
  cmd.append(args.disassembler)  # Path to IDA.
  cmd.append("-B")  # Batch mode.
  cmd.append("-S\"{}\"".format(" ".join(script_cmd)))
  cmd.append(args.binary)

  log.init(output_file=args.log_file, log_level=args.log_level)

  log.info("Executing {} {}".format(
      " ".join("{}={}".format(*e) for e in env.items()),
      " ".join(cmd)))

  try:
    with open(os.devnull, "w") as devnull:
      return subprocess.check_call(
          " ".join(cmd),
          env=env, 
          stdin=None, 
          stdout=devnull,  # Necessary.
          stderr=sys.stderr,  # For enabling `--log_file /dev/stderr`.
          shell=True,  # Necessary.
          cwd=os.path.dirname(__file__))

  except subprocess.CalledProcessError as e:
    sys.stderr.write(traceback.format_exc())
    return 1
Example #13
0
def main(config):
    log.init(config.get('server', 'log_level'))

    wm = WorkerMaster(config.get('server', 'worker_listen'), filters=config.get('filters', 'regex').split('\n'))
    pm = ProviderMaster(config.get('server', 'provider_listen'), worker_master=wm)
    try:
        wm.run()
        pm.run()
    except KeyboardInterrupt:
        wm.stop()
        pm.stop()
Example #14
0
def main():
    parser = createParser()
    args = parser.parse_args()

    log.init('root', args.verbosity, args.log_file)
    logger = logging.getLogger('root')
    logger.info('Python Dwarf Viewer started!')
    logger.debug('Args: %s', str(args))

    controller = ctrl.Controller(args)
    controller.main()
    def run(self):
        # initialize log
        log.init(
            self._ns.verbose, self._ns.quiet,
            filename="server.log", colored=False)

        # create model, that hold services for database collection
        # and memory, a wrapper object over the manipulation of the shared
        # persistent memory between queries
        model = Model()

        # define server settings and server routes
        server_settings = {
            "cookie_secret": "101010",  # todo: generate a more secure token
            "template_path": "http/templates/",
            # allow to recompile templates on each request, enable autoreload
            # and some other useful features on debug. See:
            # http://www.tornadoweb.org/en/stable/guide/running.html#debug-mode
            "debug": Conf['state'] == 'DEBUG'
        }
        # /assets/... will send the corresponding static asset
        # /[whatever] will display the corresponding template
        # other routes will display 404
        server_routes = [
            (r"/websocket", WSHandler),
            (r"/assets/([a-zA-Z0-9_\/\.-]+)/?", AssetsHandler),
            (r"/([a-zA-Z0-9_/\.=-]*)/?", TemplatesHandler),
            (r"/(.+)/?", DefaultHandler)
        ]

        # start the server.
        logging.info("Server Starts - %s state - %s:%s"
                     % (Conf['state'], Conf['server']['ip'],
                        Conf['server']['port']))
        logging.debug("Debugging message enabled.")
        application = Application(server_routes, **server_settings)
        application.listen(Conf['server']['port'])
        logging.info(
            "Connected to database: %s"
            % Conf['database']['name'])

        # start listening
        try:
            tornado.ioloop.IOLoop.instance().start()
        except KeyboardInterrupt:
            logging.info("Stopping server...")

        model.disconnect()
Example #16
0
    def start_download(download, event_download_mark_as_finished):
        log.log(__name__, sys._getframe().f_code.co_name, 'download %s' % download.to_string(), log.LEVEL_DEBUG)

        log.init('log_download_id_%d.log', download)
        download = ManageDownload.start_download(download)

        # mark link with # in file
        if download.status == Download.STATUS_FINISHED:
            # change the file permission
            log.log(__name__, sys._getframe().f_code.co_name,
                    "Change file permission %s" % download.directory.path + download.name, log.LEVEL_INFO, True,
                    download)
            os.chmod(download.directory.path + download.name, 0o777)

            if config.RESCUE_MODE is False:
                download = ManageDownload.get_download_by_id(download.id)

            log.log(__name__, sys._getframe().f_code.co_name, "Event to block file changes detection setted", log.LEVEL_INFO)
            event_download_mark_as_finished.set()
            Treatment.mark_download_finished_in_file(download)

            if config.RESCUE_MODE is False:
                actions_list = ManageDownload.get_actions_by_parameters(download_id=download.id)

                for action in actions_list:
                    object_id = None
                    if action.download_id is not None:
                        object_id = action.download_id
                    elif action.download_package_id is not None:
                        object_id = action.download_package_id

                    Treatment.action(object_id, action.id)
        else:
            if download.status == Download.STATUS_ERROR:
                Treatment.mark_download_error_in_file(download)
            else:
                download.status = Download.STATUS_WAITING

            download.time_left = 0
            download.average_speed = 0

            log.log(__name__, sys._getframe().f_code.co_name, "Updated by start_file_treatment method", log.LEVEL_DEBUG,
                    True, download)

            # change the file permission
            # log.log(__name__, sys._getframe().f_code.co_name, "Change file permission", log.LEVEL_INFO, True, download)
            # os.chmod(download.directory.path + download.name, 0o777)
        log.log(__name__, sys._getframe().f_code.co_name, '=========< End download >=========', log.LEVEL_INFO)
Example #17
0
def main():
	signal.signal(signal.SIGINT, cleanexit)
	log.init()

	collector, cabinet, broker, adc, sdc = hgw_init()
	if not nodes.init(collector) or not nodes.start():
		cleanexit(-1)

	ri = RemoteInterface()
	ri.adc = adc
	ri.sdc = sdc
	if not ri.initServers():
		cleanexit(-1)

	# TODO: cleanup here
	while True:
		time.sleep(3600)
Example #18
0
def main(argv=None):
    """Parse arguments and run the program."""

    # Parse arguments
    arguments = docopt(__doc__, argv=argv or sys.argv[1:])
    verbose = arguments.get('--verbose')
    debug = arguments.get('--debug')
    input_csv_path = arguments['<path>']

    # Configure logging
    log.init(debug=verbose)

    # Run the program
    success = run(input_csv_path, OUTPUT_CSV, OUTPUT_OSM_JSON, debug=debug)

    if not success:
        sys.exit(1)
Example #19
0
def setup():
    print ("starting Poolpi...")

    log.init()

    log.log(log.ALWAYS, "***********************************")
    log.log(log.ALWAYS, "Starting PoolPi " + VERSION + "  " + DATE)
    log.log(log.ALWAYS, "***********************************")
    cfg.VERSION = VERSION

    # init pijuice to monitor power status
    if (power.init() == ERROR):
        gv.piJuicePresent = False;

    # init equipment control
    if (equipment.init() == ERROR):
        return ERROR

    # init serial and lcd
    if (lcd.init() == ERROR):
        return ERROR

    lcd.setCursor(1,1)
    lcd.printLineCenter(VERSION)
    lcd.setCursor(2,1)
    lcd.printLineCenter(DATE)

    # init buttons
    buttons.init()

    # init event timer
    timer.init()

    # init redis
    redispy.init()

    # start temp sensor thread
    ow.init()
    if (ow.start() == ERROR):
        return ERROR

    log.log(log.ALWAYS, "setup() complete")
    return NOERROR
def main():
    log.init(2, False, filename="bulkAnalyze.log", colored=False)
    for video in genVids():
        if ('analysis' in video and video['analysis'] is not None and
            '__version__' in video['analysis'] and
            video['analysis']['__version__'] == Analyzer.__version__):
            logging.info("Skipping video %s - analysis already completed for version %s.",
                         video['path'], Analyzer.__version__)
            continue

        start_t = time.time()
        analyzer = Analyzer(
            video['_id'], video['path'], video['snapshotsFolder'], async=False,
            force=False, annotator='dfl-dlib', videoDuration=video['duration'],
            autoCleanup=True)
        data = analyzer.run()
        logging.info("Analysis completed for video %s in %s.",
                     video['path'], timeFormat(time.time() - start_t))
        model.getService('video').set(video['_id'], 'analysis', data)
Example #21
0
def configure_logging(count=0):
    """Configure logging using the provided verbosity count."""
    if count == -1:
        level = settings.QUIET_LOGGING_LEVEL
        default_format = settings.DEFAULT_LOGGING_FORMAT
        verbose_format = settings.LEVELED_LOGGING_FORMAT
    elif count == 0:
        level = settings.DEFAULT_LOGGING_LEVEL
        default_format = settings.DEFAULT_LOGGING_FORMAT
        verbose_format = settings.LEVELED_LOGGING_FORMAT
    elif count == 1:
        level = settings.VERBOSE_LOGGING_LEVEL
        default_format = settings.VERBOSE_LOGGING_FORMAT
        verbose_format = settings.VERBOSE_LOGGING_FORMAT
    elif count == 2:
        level = settings.VERBOSE2_LOGGING_LEVEL
        default_format = settings.VERBOSE_LOGGING_FORMAT
        verbose_format = settings.VERBOSE_LOGGING_FORMAT
    elif count == 3:
        level = settings.VERBOSE2_LOGGING_LEVEL
        default_format = settings.VERBOSE2_LOGGING_FORMAT
        verbose_format = settings.VERBOSE2_LOGGING_FORMAT
    else:
        level = settings.VERBOSE2_LOGGING_LEVEL - 1
        default_format = settings.VERBOSE2_LOGGING_FORMAT
        verbose_format = settings.VERBOSE2_LOGGING_FORMAT

    # Set a custom formatter
    log.init(level=level)
    log.silence('datafiles', allow_warning=True)
    logging.captureWarnings(True)
    formatter = WarningFormatter(default_format,
                                 verbose_format,
                                 datefmt=settings.LOGGING_DATEFMT)
    logging.root.handlers[0].setFormatter(formatter)

    # Warn about excessive verbosity
    if count > _Config.MAX_VERBOSITY:
        msg = "Maximum verbosity level is {}".format(_Config.MAX_VERBOSITY)
        log.warning(msg)
        _Config.verbosity = _Config.MAX_VERBOSITY
    else:
        _Config.verbosity = count
Example #22
0
def main():
    if len(sys.argv) != 2:
        print >> sys.stderr, ("Usage: %s comment_filename" % sys.argv[0])
        sys.exit(1)
    else:
        from conf import LOG_LEVEL, LOG_FILENAME, WF_LOG_FILENAME
        from conf import SEGDICT_CONF_PATH, SEGDICT_PATH
        from conf import TRAIN_NORMAL_PATH, TRAIN_SPAM_PATH

        log.init(LOG_LEVEL, LOG_FILENAME, WF_LOG_FILENAME)
        comment_file = sys.argv[1]
        
        global word_segger
        word_segger = WordSegger(SEGDICT_CONF_PATH, SEGDICT_PATH)
        model = BayesModel(TRAIN_NORMAL_PATH, TRAIN_SPAM_PATH)

        comments = load_comment(comment_file)
        for comment in comments:
            words = word_segger.get_words(comment.content)
            print '%s\t%s' % (comment,model.predict(words))
Example #23
0
def main(argv):
  if not (1 <= len(argv) <= 3):
    print ('Usage: gsoc-release.py [release repos root URL] '
           '[upstream repos root URL]')
    sys.exit(1)

  release_repos, upstream_repos = GOOGLE_SOC_REPOS, MELANGE_REPOS
  if len(argv) >= 2:
    release_repos = argv[1]
  if len(argv) == 3:
    upstream_repos = argv[2]

  log.init('release.log')

  log.info('Release repository: ' + release_repos)
  log.info('Upstream repository: ' + upstream_repos)

  r = ReleaseEnvironment(os.path.abspath('_release_'),
                         release_repos,
                         upstream_repos)
  r.interactiveMenu()
def pytest_configure(config):
    """Disable verbose output when running tests."""
    log.init(debug=True)

    terminal = config.pluginmanager.getplugin('terminal')
    base = terminal.TerminalReporter

    class QuietReporter(base):
        """Reporter that only shows dots when running tests."""

        def __init__(self, *args, **kwargs):
            {%- if cookiecutter.python_major_version == "3" %}
            super().__init__(*args, **kwargs)
            {%- else %}
            base.__init__(self, *args, **kwargs)
            {%- endif %}
            self.verbosity = 0
            self.showlongtestinfo = False
            self.showfspath = False

    terminal.TerminalReporter = QuietReporter
Example #25
0
 def test_get_logger_no_config(self, open, getQueueLogger, isdir):
     open.return_value = None
     isdir.return_value = True
     queueLogger = log.QueueLogger('virtwho')
     queueLogger.logger.handlers = []
     mockQueueLogger = Mock(wraps=queueLogger)
     getQueueLogger.return_value = mockQueueLogger
     options = Mock()
     options.debug = False
     options.background = True
     options.log_file = log.DEFAULT_LOG_FILE
     options.log_dir = log.DEFAULT_LOG_DIR
     options.log_per_config = False
     log.init(options)
     main_logger = log.getLogger(name='main')
     self.assertTrue(main_logger.name == 'virtwho.main')
     self.assertTrue(len(main_logger.handlers) == 1)
     self.assertTrue(isinstance(main_logger.handlers[0], log.QueueHandler))
     queue_handlers = queueLogger.logger.handlers
     self.assertTrue(len(queue_handlers) == 1)
     self.assertEquals(queue_handlers[0].baseFilename, '%s/%s' % (log.DEFAULT_LOG_DIR, log.DEFAULT_LOG_FILE))
Example #26
0
def main():
    ns = parse_args()
    log.init(verbose=ns.verbose, quiet=ns.quiet) 
    logging.info("Game is starting...");
    game = Game()
    try:
        game.run()
    except BaseException as e:
        logging.exception("An unexpected error occured during game run.")
        game.cleanUp()
    logging.info("Total game running time: %s" % guess_time_unit(
        time.time() - game.init_time))
    logging.info("Average rendering time: %.5fs" % 
        game.getAverageRenderingTime())
    logging.info("Average updating time: %.5fs" %
        game.getAverageUpdatingTime())
    logging.info("Average FPS: %.2f" % game.getAverageFPS())
    if game.getAverageUpdatingTime() > conf['game_engine']['update_time_step']:
        logging.warning("\tAverage updating time is too long!")
        logging.warning("\t Shoud be <= %.5f" 
                        % conf['game_engine']['update_time_step']);
Example #27
0
def new_game():
    fighter_component = components.Fighter(hp=30,
                                           defence=2,
                                           power=5,
                                           death_function=player_death)
    player = components.Entity(0,
                               0,
                               'player',
                               config.TILE_PLAYER,
                               libtcodpy.white,
                               is_walkable=False,
                               fighter=fighter_component)
    player.inventory = []
    player.inventory_size = 26
    player.game_state = 'playing'
    log.init()
    log.add_message("You awaken in a vault.")
    player.current_map = mapmaker.make_map(player)
    renderer.clear_console()

    return player
Example #28
0
def init_stage1():
    """\
    Initialise paths for wxGlade (first stage)

    Initialisation is split because the test suite doesn't work with proper
    initialised paths.

    Initialise locale settings too. The determined system locale will be
    stored in L{config.encoding}.
    """
    config.version = config.get_version()
    common.init_paths()

    # initialise own logging extensions
    log.init(filename=config.log_file, encoding='utf-8', level='INFO')
    atexit.register(log.deinit)

    # print versions
    logging.info(_('Starting wxGlade version "%s" on Python %s'),
                 config.version, config.py_version)

    # print used paths
    logging.info(_('Base directory:             %s'), config.wxglade_path)
    logging.info(_('Documentation directory:    %s'), config.docs_path)
    logging.info(_('Icons directory:            %s'), config.icons_path)
    logging.info(_('Build-in widgets directory: %s'), config.widgets_path)
    logging.info(_('Template directory:         %s'), config.templates_path)
    logging.info(_('Credits file:               %s'), config.credits_file)
    logging.info(_('License file:               %s'), config.license_file)
    logging.info(_('Manual file:                %s'), config.manual_file)
    logging.info(_('Tutorial file:              %s'), config.tutorial_file)
    logging.info(_('Home directory:             %s'), config.home_path)
    logging.info(_('Application data directory: %s'), config.appdata_path)
    logging.info(_('Configuration file:         %s'), config.rc_file)
    logging.info(_('History file:               %s'), config.history_file)
    logging.info(_('Log file:                   %s'), config.log_file)

    # adapt application search path
    sys.path.insert(0, config.wxglade_path)
    sys.path.insert(1, config.widgets_path)
Example #29
0
    def start_file_treatment(file_path):
        log.init('start_file_treatement.log')
        # log.init_log_file('start_file_treatement.log', config.application_configuration.python_log_format)

        log.log(__name__, sys._getframe().f_code.co_name, 'file_path %s' % file_path, log.LEVEL_DEBUG)

        log.log(__name__, sys._getframe().f_code.co_name, '=========> Insert new links or update old in database <=========',
                log.LEVEL_INFO)
        downloads_to_mark_as_finished_in_file = []
        links_to_mark_as_error_in_file = []

        # insert links in database
        file = open(file_path, 'r', encoding='utf-8')
        for line in file:
            if 'http' in line:
                log.log(__name__, sys._getframe().f_code.co_name, 'Line %s contains http' % line, log.LEVEL_DEBUG)
                download = ManageDownload.insert_update_download(line, file_path)

                if download is not None:
                    if download.status == Download.STATUS_FINISHED and ManageDownload.MARK_AS_FINISHED not in line:
                        log.log(__name__, sys._getframe().f_code.co_name,
                            'Download id %s already finished in database but not marked in file => mark as finished',
                            log.LEVEL_INFO)
                        downloads_to_mark_as_finished_in_file.append(download)
                else:
                    if ManageDownload.MARK_AS_ERROR not in line and ManageDownload.MARK_AS_FINISHED not in line:
                        links_to_mark_as_error_in_file.append(line)

        file.close()

        for download_to_mark_as_finished in downloads_to_mark_as_finished_in_file:
            Treatment.mark_download_finished_in_file(download_to_mark_as_finished)

        for link_to_mark_as_finished in links_to_mark_as_error_in_file:
            Treatment.mark_link_error_in_file(file_path, link_to_mark_as_finished)

        log.log(__name__, sys._getframe().f_code.co_name,
            '=========< End insert new links or update old in database >=========',
            log.LEVEL_INFO)
Example #30
0
def manage_session(test_mode):
    log.init()

    if not mydbus.dbus_version_ok and not xxmlrpc.working:
        rox.alert(problem_msg)

    set_up_environment()
    session.init()
    children.init()
    session_dbus.init()  # Start even if DBus is too old, for session bus
    xml_settings = settings.init()

    if mydbus.dbus_version_ok:
        service = dbus.service.BusName(constants.session_service,
                                       bus=session_dbus.get_session_bus())
        SessionObject3x(service)

    # This is like the D-BUS service, except using XML-RPC-over-X
    xml_service = xxmlrpc.XXMLRPCServer(constants.session_service)
    xml_service.add_object('/Session', XMLSessionObject())
    xml_service.add_object('/Settings', xml_settings)

    try:
        if test_mode:
            print "Test mode!"
            print "Started", os.system(
                "(/bin/echo hi >&2; sleep 4; date >&2)&")
            print "OK"
        else:
            try:
                wm.start()
            except:
                rox.report_exception()

        g.main()
    finally:
        session_dbus.destroy()
Example #31
0
    def test_get_logger_different_log_file(self, getFileHandler, getQueueLogger):
        queueLogger = log.QueueLogger('virtwho')
        queueLogger.logger.handlers = []
        mockQueueLogger = Mock(wraps=queueLogger)
        getQueueLogger.return_value = mockQueueLogger

        config = Mock()
        config.name = 'test'
        config.log_file = 'test.log'
        config.log_dir = '/test/'

        options = Mock()
        options.debug = False
        options.background = True
        options.log_per_config = True
        options.log_dir = ''
        options.log_file = ''
        log.init(options)
        test_logger = log.getLogger(name='test', config=config)

        self.assertTrue(test_logger.name == 'virtwho.test')
        self.assertTrue(len(test_logger.handlers) == 1)
        self.assertTrue(len(queueLogger.logger.handlers) == 1)
        getFileHandler.assert_called_with(name=test_logger.name, config=config)
Example #32
0
def main():

    signal.signal(signal.SIGTERM, handler)

    if TEST:
        log.initdebug()

    myconfig = config.Config(sys.argv)
    log.init(myconfig)

    if TEST:
        test.remote_test.start(myconfig)

    try:
        app = Application(myconfig)
        app.poll()
        app.stop()

    except Exception, e:

        logging.getLogger("log").critical(str(e))

        if TEST:
            raise
Example #33
0
def run():

    init_interface_folders()

    logger = log.init()
    logger.info(f'НАЧАЛО:КОНВЕРТАЦИЯ ДАННЫХ API')
    json_converter.run(sys.argv, logger)
    logger.info(f'КОНЕЦ:КОНВЕРТАЦИЯ ДАННЫХ API')

    logger.info(f'НАЧАЛО:АРХИВАЦИЯ КАРТИНОК API')
    to_zip_media.run(logger)
    logger.info(f'КОНЕЦ:АРХИВАЦИЯ КАРТИНОК API')

    logger.info(f'НАЧАЛО:ТРАНСПОРТИРОВКА ПАКЕТОВ API')
    api_transport.run(logger)
    logger.info(f'КОНЕЦ:ТРАНСПОРТИРОВКА ПАКЕТОВ API')
Example #34
0
def init_logging():
    import log
    log.init()
    log.message('Initialized logging')
from __future__ import unicode_literals

import cv2
import sys
import os

from conf import Conf
import log
from lib.DeepFaceLab.mainscripts.Extractor import ExtractSubprocessor
from lib.DeepFaceLab.facelib.LandmarksProcessor import landmarks_68_pt
from tools.analyzer.dflAnnotator import MTDFLAnnotator, DLIBDFLAnnotator

COLORS = [(0, 255, 0), (0, 0, 255), (255, 0, 0), (255, 255, 0), (255, 0, 255),
          (0, 255, 255), (0, 0, 0), (255, 255, 255)]

log.init(3, False, filename="experiment.log", colored=False)


def debugrect(data, result):
    filename, faces = result
    if len(faces) <= 0:
        return
    image = cv2.imread(filename)

    if image is None:
        print("Couldn't find: %s" % (filename))
        return

    for fidx, face in enumerate(faces):
        (x, y, x2, y2, confidence) = face
        cv2.rectangle(image, (x, y), (x2, y2), COLORS[fidx % len(COLORS)], 1)
Example #36
0
def main():
    log.init()
    Application()
Example #37
0
def pytest_configure(config):
    log.init(debug=True)
    log.silence('selenium', allow_warning=True)
Example #38
0
    backup_ceph_host = None

    for param, val in opts:
        if param == "--domain":
            az_domain = val
        elif param == "--backup_domain":
            backup_az_domain = val

        elif param == "--host":
            ceph_host = val
        elif param == "--backup_host":
            backup_ceph_host = val

        elif param == "--help":
            usage()
            sys.exit(0)
        else:
            print "unhandled param"
            sys.exit(3)
    LOG.info("domain=%s, backup_domain=%s, host=%s, backup_host=%s" %
             (az_domain, backup_az_domain, ceph_host, backup_ceph_host))
    backup_az(az_domain, backup_az_domain, ceph_host, backup_ceph_host)


if __name__ == "__main__":
    LOG.init("ceph backup az")
    LOG.info('START to set ceph backup az...')
    argv = sys.argv
    main(argv)
    LOG.info('END set ceph backup az...')
Example #39
0
    def start_multi_downloads(self, file_path):
        download = ManageDownload.get_download_to_start(None, file_path)

        while not self.stop_loop_file_treatment and download is not None:
            log.init('log_download_id_%d.log', download)
            # log.init_log_file('log_download_id_%d.log', config.application_configuration.python_log_format)

            log.log(__name__, sys._getframe().f_code.co_name, '=========> Start new download <=========', log.LEVEL_INFO)
            if config.RESCUE_MODE is False:
                config.application_configuration = ManageDownload.get_application_configuration_by_id(config.application_configuration.id_application, download)
                if config.application_configuration is None:
                    log.init('log_download_id_%d.log', download)
                    # on utilise la nouvelle configuration pour le log console
                    # log.init_log_console(config.application_configuration.python_log_format)
                    # on initialise le log qui sera utilise pour envoyer directement a l'ihm
                    # log.init_log_stream(config.application_configuration.python_log_format)
            else:
                # si on est en rescue mode on a pas acces a la base donc on considere que le telechargement est active
                config.application_configuration = ApplicationConfiguration()
                config.application_configuration.download_activated = True

            if config.application_configuration.download_activated:
                download = ManageDownload.start_download(download)

                # mark link with # in file
                if download.status == Download.STATUS_FINISHED:
                    #change the file permission
                    log.log(__name__, sys._getframe().f_code.co_name, "Change file permission %s" % download.directory.path + download.name, log.LEVEL_INFO, True, download)
                    os.chmod(download.directory.path + download.name, 0o777)

                    if config.RESCUE_MODE is False:
                        download = ManageDownload.get_download_by_id(download.id)

                    Treatment.mark_download_finished_in_file(download)

                    if config.RESCUE_MODE is False:
                        actions_list = ManageDownload.get_actions_by_parameters(download_id=download.id)

                        for action in actions_list:
                            object_id = None
                            if action.download_id is not None:
                                object_id = action.download_id
                            elif action.download_package_id is not None:
                                object_id = action.download_package_id

                            Treatment.action(object_id, action.id)
                else:
                    if download.status == Download.STATUS_ERROR:
                        Treatment.mark_download_error_in_file(download)
                    else:
                        download.status = Download.STATUS_WAITING

                    download.time_left = 0
                    download.average_speed = 0

                    log.log(__name__, sys._getframe().f_code.co_name, "Updated by start_file_treatment method", log.LEVEL_DEBUG, True, download)

                    #change the file permission
                    # log.log(__name__, sys._getframe().f_code.co_name, "Change file permission", log.LEVEL_INFO, True, download)
                    # os.chmod(download.directory.path + download.name, 0o777)
                log.log(__name__, sys._getframe().f_code.co_name, '=========< End download >=========', log.LEVEL_INFO)
                # next download
                download = ManageDownload.get_download_to_start(None, file_path)
            else:
                log.log(__name__, sys._getframe().f_code.co_name, 'Wait 60 seconds...', log.LEVEL_INFO, True, download)
                # on attend 60s avant de retenter un telechargement
                time.sleep(60)
Example #40
0
import args, params
args_and_params = args.args_and_params()
globals().update(args_and_params)
if not 'simulation_id' in args_and_params:
	simulation_id = "pop_%d_G_%d_s_%g_H_%g_U_%g_beta_%g_pi_%g_tau_%g_" % (pop_size,G,s,H,U,beta,pi,tau)
	simulation_id += datetime.now().strftime('%Y-%b-%d_%H-%M-%S-%f')
	args_and_params['simulation_id'] = simulation_id
params_filename = cat_file_path(params_ext)
make_path(params_filename)
params.save(params_filename, args_and_params)

# load logging
import log
log_filename = cat_file_path(log_ext)
make_path(log_filename)
log.init(log_filename, console, debug)
logger = log.get_logger('simulation')

# log initial stuff
logger.info("Simulation ID: %s", simulation_id)
logger.info("Logging to %s", log_filename)
logger.info("Parametes from file and command line: %s", params.to_string(args_and_params, short=True))
logger.info("Parameters saved to file %s", params_filename)

def run():
	tic = clock()

	# init population
	w = smooth_fitness(s, H, 3, G)	
	if SIMe:
		logger.info("SIMe mode - using pi=0 and tau=1 until MSB is reached")
Example #41
0
def main():
    log.init()
    app = QtGui.QApplication(sys.argv)
    qb = TerminalViewer(app)
    main_window = MainWindow(qb)
    sys.exit(app.exec_())
Example #42
0
__author__ = 'Administrator'
import log as LOG
LOG.init('hwcloud')
Example #43
0
import json
import os

import log  # type: ignore

import hyp2rem.utils
from hyp2rem import hypothesis as hyp
from hyp2rem import remnote as rem

HYP_KEY = os.environ["HYP_KEY"]
REM_KEY = os.environ["REM_KEY"]
REM_USER = os.environ["REM_USER"]

log.reset()
log.init(verbosity=3)


def test_document_for_source():
    """Test creating/getting RemNote documents for Hypothes.is source URIs."""
    group_id = hyp.get_group_by_name(HYP_KEY, "RemNote")["id"]
    annotations = hyp.get_annotations(HYP_KEY, group=group_id)
    for annotation in annotations:
        document_rem = hyp2rem.utils.document_for_source(
            REM_KEY,
            REM_USER,
            annotation=annotation,
        )
        log.debug("Retrived document:" +
                  json.dumps(document_rem.source, indent=4))
        assert (annotation["target"][0]["source"]
Example #44
0
                "")  # remove part [fullResultAnswer] from chunk

            fullResultAnswer = fullResultAnswer.strip()
            fullResultAnswersLst.insert(0, fullResultAnswer)

            regExpStr = r"(^<\/div>(<\/font>)* ?(<p>)*(\n|\\n)*(<p>)*-?((\n|\\n)*-?<br>)*|^<br>|^<\/br>|^<font.*?><br>|^<font.*?>(\n|\\n)<br>|<br>$|<\/br>$|(<\/p>)*(<\/div>)*(<\/h2>)*$|<font.*?>|<\/font><\/h2>|<\/font>|<b>|<\/b>)"
            fullResultAnswerFixed = general_stuff.removeHtmlTags(
                fullResultAnswer, rmHtmlTagsRegExpStr, re.IGNORECASE)
            fullResultAnswerFixed = fullResultAnswerFixed.strip()
            fullResultAnswerFixedLst.insert(0, fullResultAnswerFixed)
        else:
            break
        pass

    parsedChunk["answer"] = fullResultAnswersLst
    parsedChunk["answer_edited"] = fullResultAnswerFixedLst
    parsedChunk["answers_count"] = len(fullResultWhoAnswersLst)
    parsedChunk["is_done"] = True
    return parsedChunk


#endregion Functions

#region Startup
logger = log.init()
if __name__ == "__main__":
    if logger:
        logger.info(f"This module is executing")
else:
    logger.info(f"This module is imported")
#endregion Startup
import db
import log as logger
import config

logger.init("load_images.py")

DB = 'test'
db.connect(DB)

faces = [["obama.jpg", "Barack Obama", "022798129"],
         ["biden.jpg", "Joe Biden", "039436788"],
         ["tanya.jpg", "Tanya S.", "0962536559"],
         ["bingo.jpg", "Bingo", "0962536366"],
         ["lulliya.jpg", "Lulliya", "025051147"]]

#Save DB
for face in faces:
    db.save2DB(face)
Example #46
0
def main():
    log.init()
    log.silence("datafiles", "selenium", "urllib3")
Example #47
0
# coding: utf-8

from flask import Flask, request, render_template
from flask_cors import CORS
from db import myredis
from config import *

import json
import api
import log

app = Flask('web')
CORS(app, supports_credentials=True)
app.secret_key = 'ABCAz47j22AA#R~X@H!jLwf/A'
log.init()


@app.route('/api/result/<channel>', methods=['post'])
@api.handle_api_zsq('/api/result', 'post')
def result(channel):
    #[{
    #     "send_time":"2020-07-03 12:53:10",
    #     "report_time":"2020-07-03 12:53:16",
    #     "success":true,
    #     "err_msg":"用户接收成功",
    #     "err_code":"DELIVERED",
    #     "phone_number":"13031046676",
    #     "sms_size":"1",
    #     "biz_id":"706715193751989145^0"
    # }]
    if channel == Ali.channel_name:
Example #48
0
        log.info('Start to restart openstack service for nova/neutron/cinder.')
        cps_service = CPSServiceBusiness()
        for proxy in self.proxy_match_region.keys():
            cps_service.stop_all(proxy)
            cps_service.start_all(proxy)
        log.info(
            'Finish to restart openstack service for nova/neutron/cinder.')

    def verify_services_status(self):
        cps_service = CPSServiceBusiness()
        for proxy in self.proxy_match_region.keys():
            cps_service.check_all_service_template_status(proxy)


if __name__ == '__main__':
    log.init('patches_tool_config')
    config.export_env()

    print(
        'Start to patch Hybrid-Cloud patches in cascading node and proxy nodes...'
    )
    log.info(
        'Start to patch Hybrid-Cloud patches in cascading node and proxy nodes...'
    )

    patches_tool = PatchesTool()
    patches_tool.patch_for_cascading_and_proxy_node()

    print(
        'Finish to patch Hybrid-Cloud patches in cascading node and proxy nodes...'
    )
Example #49
0
# -*- coding:utf-8 -*-
__author__ = 'q00222219@huawei'

import sys
sys.path.append('/usr/bin/install_tool')
from heat.openstack.common import log as logging
import log as logger
import cps_server
import threading
import install.aws_proxy_install as aws_installer

proxy_manager_lock = threading.Lock()

LOG = logging.getLogger(__name__)

logger.init('CloudManager')


def distribute_proxy():
    proxy_manager_lock.acquire()
    try:
        host_list = cps_server.cps_host_list()
        hosts = host_list["hosts"]
        free_proxy_list = []
        allocated_proxy_nums = []

        for host in hosts:
            proxy_info = {
                "id": host["id"],
                "status": host["status"],
                "manageip": host["manageip"]
Example #50
0
        log.info('Start to restart openstack service for nova/neutron/cinder.')
        cps_service = CPSServiceBusiness()
        for proxy in self.proxy_match_region.keys():
            cps_service.stop_all(proxy)
            cps_service.start_all(proxy)
        log.info(
            'Finish to restart openstack service for nova/neutron/cinder.')

    def verify_services_status(self):
        cps_service = CPSServiceBusiness()
        for proxy in self.proxy_match_region.keys():
            cps_service.check_all_service_template_status(proxy)


if __name__ == '__main__':
    log.init('patches_tool_config')
    config.export_env()

    print(
        'Start to patch Hybrid-Cloud patches in cascading node and proxy nodes...'
    )
    log.info(
        'Start to patch Hybrid-Cloud patches in cascading node and proxy nodes...'
    )

    patches_tool = PatchesTool()
    patches_tool.patch_for_cascading_and_proxy_node()

    print(
        'Finish to patch Hybrid-Cloud patches in cascading node and proxy nodes...'
    )
Example #51
0
import os
import traceback

import log
from app.fbs import BaseApplicationContext

import sys
import PySide2.QtWidgets as QtWidgets

if __name__ == '__main__':
    fbs = BaseApplicationContext()  # 1. Instantiate ApplicationContext
    # setup ui
    try:
        log.init(fbs.get_resource())
    except Exception as e:
        QtWidgets.QMessageBox.critical(
            None, 'Log Create Error',
            f'Log file is not created successfully. Error is {e}')
        exit(-1)

    exit_code = 1
    try:
        from widgets.toast import Toast
        from mainWindow import MainWindow

        Toast.settings['iconsPath'] = fbs.get_resource(
            os.path.join('icons', 'toast'))
        mainWindow = MainWindow()
        mainWindowQss = fbs.qss('mainWindow.qss')
        if mainWindowQss is not None:
            mainWindow.setStyleSheet(mainWindowQss)
Example #52
0
# -*- coding: utf-8 -*-
import sys, os, time, threading

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)).replace('\\', '/') + '/module')
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)).replace('\\', '/') + '/item')
import kiwoom, cmd, log, contract, subject, calc, tester, dbinsert, dbsubject, my_util, gmail
import define as d
import log_result as res
# import matplotlib.pyplot as plt
import datetime
import health_server

kw = None

if __name__ == "__main__":
    log.init(os.path.dirname(os.path.abspath(__file__).replace('\\', '/')))
    res.init(os.path.dirname(os.path.abspath(__file__).replace('\\', '/')))

    d.mode = 0

    if len(sys.argv) == 1:
        print('실제투자(1), 테스트(2), DB Insert(3)')
        d.mode = int(input())

    else:
        d.mode = int(sys.argv[1])

    # cmd.init()
    if d.get_mode() == 1:

        try:
Example #53
0
 def test_log_init(self, mock_add_handler, mock_set_logging):
     log.init('DEBUG')
     mock_set_logging.assert_called_once_with(logging.DEBUG)
     mock_add_handler.assert_called_once()
Example #54
0
import sys, os
reload(sys)
sys.setdefaultencoding('utf-8')

from os.path import abspath, dirname, join, normpath
PREFIX = normpath(dirname(abspath(__file__)))
for path in (PREFIX, normpath(join(PREFIX, '../lib'))):
    if path not in sys.path:
        sys.path = [path] + sys.path

import config
SERVER_NAME = 'CHARACTERSERVER'
config.init(SERVER_NAME)
import log
log.init(config.log_threshold)
'''
from syslogger import init_logger
syslog_conf = config.syslog_conf.split(',')
if len(syslog_conf) > 1:
    syslog_conf = (syslog_conf[0], int(syslog_conf[1]))
else:
    syslog_conf = syslog_conf[0]
init_logger( syslog_conf )
'''
from server import server
from datetime import datetime

reactor.addSystemEventTrigger('before', 'shutdown', server.cleanup)
application = service.Application(SERVER_NAME)
Example #55
0
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import webob.dec
import base64
import hashlib
import log
import json
from cinder import wsgi
from cinder.openstack.common import timeutils
from cinder import HWExtend
from oslo.config import cfg

CONF = cfg.CONF

log.init('cinder-api')
APACHE_TIME_FORMAT = '%d/%b/%Y:%H:%M:%S'
APACHE_LOG_FORMAT = (
    '%(remote_addr)s - %(remote_user)s [%(datetime)s] "%(method)s %(url)s '
    '%(http_version)s" %(status)s %(content_length)s')

DRM_LOG_FORMAT = ('%(remote_addr)s - %(remote_user)s - %(token_id)s '
                  '[%(request_datetime)s][%(response_datetime)s]'
                  ' %(method)s %(url)s %(http_version)s %(status)s'
                  ' %(content_length)s %(request_body)s %(instance_id)s')


class AccessLogMiddleware(wsgi.Middleware):
    """Writes an access log to INFO."""
    @webob.dec.wsgify
    def __call__(self, request):
Example #56
0
import sys

reload(sys)
sys.setdefaultencoding("utf-8")
import webob.dec
import base64
import hashlib
import log
from neutron import wsgi
from neutron.openstack.common import timeutils
from neutron import HWExtend

log.init("neutron-api")
APACHE_TIME_FORMAT = "%d/%b/%Y:%H:%M:%S"
APACHE_LOG_FORMAT = (
    '%(remote_addr)s - %(remote_user)s [%(datetime)s] "%(method)s %(url)s '
    '%(http_version)s" %(status)s %(content_length)s'
)
DRM_LOG_FORMAT = (
    "%(remote_addr)s - %(remote_user)s - %(token_id)s "
    "[%(request_datetime)s][%(response_datetime)s]"
    " %(method)s %(url)s %(http_version)s %(status)s"
    " %(content_length)s %(request_body)s"
)


class AccessLogMiddleware(wsgi.Middleware):
    """Writes an access log to INFO."""

    @webob.dec.wsgify
    def __call__(self, request):
Example #57
0
def pls_parse(data):
    fp_data = StringIO.StringIO(data)
    playlist = ConfigParser.ConfigParser()
    playlist.readfp(fp_data)

    urls = []
    for i in xrange(1, playlist.getint('playlist', 'numberofentries') + 1):
        urls.append(playlist.get('playlist', 'File%d' % i))

    return urls

class PlaylistFetcher(pykka.ThreadingActor):
    def fetch(self, url):
        try:
            request = requests.get(url)
            urls = pls_parse(request.text)
        except Exception, e:
            logger.error(e)
            return []
        else:
            return urls


if __name__ == '__main__':
    import log

    log.init()
    fetcher = PlaylistFetcher.start().proxy()
    print fetcher.fetch('http://somafm.com/groovesalad.pls').get()
    fetcher.stop()
Example #58
0
def init_logging():
    import log
    log.init()
    log.message('Initialized logging')
Example #59
0
                        dest='global_shift',
                        default=True)
    parser.add_argument('--invert',
                        help="invert color range",
                        dest='invert',
                        action='store_true',
                        default=False)

    args = parser.parse_args()

    # local mode
    if args.rom == None:
        print("Need --rom parameter")
        sys.exit(-1)

    log.init(args.debug)
    logger = log.get('Palette')

    if args.seed == 0:
        random.seed(random.randint(0, 9999999))
    else:
        random.seed(args.seed)

    settings = {
        # global same shift for everything flag
        "global_shift": True,

        #set to True if all suits should get a separate hue-shift degree
        "individual_suit_shift": False,

        #set to True if all tileset palettes should get a separate hue-shift degree