예제 #1
0
def parse_args():
    """Read and parse options from command line
	Initialize logging

	Return values:
	options: options and arguments parsed from command line
	confs: configuration file dictionary information
	"""
    usage = """usage: %prog [options]
To crawl pages from web in terms of special URL patterns."""

    parser = optparse.OptionParser(usage=usage, version='%prog 1.0.0.0')
    parser.add_option('-c',
                      dest='filename',
                      help='read config file',
                      metavar='FILE')

    parser.add_option('-l',
                      '--log',
                      dest='log',
                      action='store_true',
                      help='start logging',
                      default=False)

    options, args = parser.parse_args()
    if options.filename is None:
        print parser.format_help()
        parser.exit()
    else:
        confs = utils.parse_config_file(options.filename)
        if options.log:
            log.read_config_file(confs['log']['log_config_file'])
            log.install(confs['log']['log_name'])
        else:
            log.uninstall()

        return options, confs
예제 #2
0
        log.handle_error(ex)

    finally:

        # shut down our database connection
        db.shutdown()

        # shut down the localization/internationalization system
        i18n.uninstall()

        # make sure the Winform exception handler is removed
        Application.ThreadException -=\
           ThreadExceptionEventHandler(exception_handler)

        # shut down the logging system
        log.uninstall()


# ============================================================================
def __validate_environment():
    '''
   Checks to see if the current environment is valid to run this script in.
   If it is not, an error message is displayed to explain the problem.
   
   Returns True if the current environment is valid, False if it is not.
   '''

    # the minimum versions required for a valid environment
    REQUIRED_MAJOR = 0
    REQUIRED_MINOR = 9
    REQUIRED_BUILD = 165
      log.handle_error(ex)
         
   finally:
      
      # shut down our database connection
      db.shutdown()
      
      # shut down the localization/internationalization system
      i18n.uninstall()
      
      # make sure the Winform exception handler is removed
      Application.ThreadException -=\
         ThreadExceptionEventHandler(exception_handler)
         
      # shut down the logging system
      log.uninstall()


      
# ============================================================================      
def __validate_environment():
   '''
   Checks to see if the current environment is valid to run this script in.
   If it is not, an error message is displayed to explain the problem.
   
   Returns True if the current environment is valid, False if it is not.
   '''
   
   # the minimum versions required for a valid environment
   REQUIRED_MAJOR=0
   REQUIRED_MINOR=9
예제 #4
0
 def run(self, result):
    # overridden to install our logging framework during unit tests!
    log.install(None)
    super(AllTests, self).run(result)
    log.uninstall()