Пример #1
0
  def test_setup_environment_and_remove_temp_files(self):
    """
    Test if the temporary files are deleted.
    """
    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_remove_temp_files')
    scanner.tmp_dir = 'test_remove_temp_files'
    scanner.creative_db = 'sqlite:///%s/creative.db' % scanner.log_dir

    scanner.setup_environment()
    assert os.path.exists(scanner.workspace.dirname)

    scanner.remove_temp_files()
    self.assertFalse(os.path.exists(scanner.workspace.dirname))

    adscan.fs.rmdirs(scanner.log_dir)
    adscan.fs.rmdirs(scanner.tmp_dir)
Пример #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)
Пример #3
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)
Пример #4
0
    def test_setup_environment_and_remove_temp_files(self):
        """
    Test if the temporary files are deleted.
    """
        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_remove_temp_files')
        scanner.tmp_dir = 'test_remove_temp_files'
        scanner.creative_db = 'sqlite:///%s/creative.db' % scanner.log_dir

        scanner.setup_environment()
        assert os.path.exists(scanner.workspace.dirname)

        scanner.remove_temp_files()
        self.assertFalse(os.path.exists(scanner.workspace.dirname))

        adscan.fs.rmdirs(scanner.log_dir)
        adscan.fs.rmdirs(scanner.tmp_dir)