Esempio n. 1
0
def main():
  """
  The main method to launch the scanner.
  """
  # Move to the project directory.
  project_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)
  os.chdir(project_dir)

  conf_file = os.path.join('conf', CONFIG_FILE)
  config = SafeConfigParser()
  config.read(conf_file)

  scanner = Scanner(config)
  scanner.setup_environment()

  if get_boolean(config, 'Steps', 'download_new_creative_ids'):
    scanner.download_new_creative_ids()

  if get_boolean(config, 'Steps', 'download_creatives'):
    scanner.download_creatives()

  if get_boolean(config, 'Steps', 'browse_creatives'):
    scanner.browse_creatives('https')

  if get_boolean(config, 'Steps', 'browse_creatives_over_http'):
    scanner.browse_creatives('http')

  if get_boolean(config, 'Steps', 'check_compliance'):
    scanner.check_compliance()

  if get_boolean(config, 'Steps', 'upload_creatives'):
    scanner.upload_creatives()

  if get_boolean(config, 'Steps', 'compress_log_file'):
    scanner.compress_log_file()

  if get_boolean(config, 'Steps', 'remove_temp_files'):
    scanner.remove_temp_files()

  sys.exit(0)
Esempio n. 2
0
def main():
    """
  The main method to launch the scanner.
  """
    # Move to the project directory.
    project_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)
    os.chdir(project_dir)

    conf_file = os.path.join('conf', CONFIG_FILE)
    config = SafeConfigParser()
    config.read(conf_file)

    scanner = Scanner(config)
    scanner.setup_environment()

    if get_boolean(config, 'Steps', 'download_new_creative_ids'):
        scanner.download_new_creative_ids()

    if get_boolean(config, 'Steps', 'download_creatives'):
        scanner.download_creatives()

    if get_boolean(config, 'Steps', 'browse_creatives'):
        scanner.browse_creatives('https')

    if get_boolean(config, 'Steps', 'browse_creatives_over_http'):
        scanner.browse_creatives('http')

    if get_boolean(config, 'Steps', 'check_compliance'):
        scanner.check_compliance()

    if get_boolean(config, 'Steps', 'upload_creatives'):
        scanner.upload_creatives()

    if get_boolean(config, 'Steps', 'compress_log_file'):
        scanner.compress_log_file()

    if get_boolean(config, 'Steps', 'remove_temp_files'):
        scanner.remove_temp_files()

    sys.exit(0)
Esempio n. 3
0
  def test_compress_log_file(self):
    """
    Test if the log file is compressed.
    """
    conf_file = os.path.join('conf', CONFIG_FILE)
    config = SafeConfigParser()
    config.read(conf_file)

    scanner = Scanner(config)
    scanner.log_dir = os.path.join(scanner.logroot_dir, 'test_compress_log_file')

    tarname = '%s.tgz' % scanner.log_dir

    scanner.setup_environment()
    assert os.path.exists(scanner.log_dir)
    if os.path.exists(tarname):
      os.remove(tarname)

    scanner.compress_log_file()
    assert os.path.exists(tarname)

    adscan.fs.rmdirs(scanner.log_dir)
    os.remove(tarname)
Esempio n. 4
0
    def test_compress_log_file(self):
        """
    Test if the log file is compressed.
    """
        conf_file = os.path.join('conf', CONFIG_FILE)
        config = SafeConfigParser()
        config.read(conf_file)

        scanner = Scanner(config)
        scanner.log_dir = os.path.join(scanner.logroot_dir,
                                       'test_compress_log_file')

        tarname = '%s.tgz' % scanner.log_dir

        scanner.setup_environment()
        assert os.path.exists(scanner.log_dir)
        if os.path.exists(tarname):
            os.remove(tarname)

        scanner.compress_log_file()
        assert os.path.exists(tarname)

        adscan.fs.rmdirs(scanner.log_dir)
        os.remove(tarname)