Esempio n. 1
0
 def handle(self, *args, **opt):
   assert not args
   util.log_setup(opt['debug'])
   try:
     self._handle(opt)
   except d1_common.types.exceptions.DataONEException as e:
     raise django.core.management.base.CommandError(str(e))
Esempio n. 2
0
    def handle(self, *args, **options):
        util.log_setup(options['debug'])
        # logging.basicConfig(level=logging.DEBUG)
        # if options['debug']:
        #   logger = multiprocessing.log_to_stderr()
        #   logger.setLevel(multiprocessing.SUBDEBUG)

        logging.info('Running management command: {}'.format(__name__))
        util.exit_if_other_instance_is_running(__name__)
        run_start_sec = time.time()
        event_counter = d1_common.util.EventCounter()

        try:
            # profiler = profile.Profile()
            # profiler.runcall(handle)
            # profiler.print_stats()
            self._handle(options, event_counter)
        except Exception as e:
            logging.error(str(e))
            event_counter.dump_to_log()
            raise django.core.management.base.CommandError(str(e))

        event_counter.dump_to_log()
        total_run_sec = time.time() - run_start_sec
        logging.info(
            'Completed. total_run_sec={:.02f} total_run_dhm="{}"'.format(
                total_run_sec,
                d1_common.util.format_sec_to_dhm(total_run_sec)))
 def handle(self, *args, **opt):
     assert not args
     util.log_setup(opt['debug'])
     logging.info('Running management command: {}'.format(
         __name__)  # util.get_command_name())
                  )
     util.exit_if_other_instance_is_running(__name__)
     util.abort_if_stand_alone_instance()
     try:
         self._handle(opt)
     except d1_common.types.exceptions.DataONEException as e:
         raise django.core.management.base.CommandError(str(e))
Esempio n. 4
0
 def handle(self, *args, **opt):
   util.log_setup(opt['debug'])
   logging.info('test')
   logging.info('Running management command: {}'.format(__name__))
   util.exit_if_other_instance_is_running(__name__)
   self._opt = opt
   try:
     # profiler = profile.Profile()
     # profiler.runcall(self._handle)
     # profiler.print_stats()
     self._handle()
   except d1_common.types.exceptions.DataONEException as e:
     logging.error(str(e))
     raise django.core.management.base.CommandError(str(e))
   self._events.dump_to_log()
Esempio n. 5
0
 def handle(self, *args, **opt):
     util.log_setup(opt['debug'])
     logging.info('Running management command: {}'.format(
         __name__)  # util.get_command_name())
                  )
     util.exit_if_other_instance_is_running(__name__)
     self._check_debug_mode()
     if opt['root'] and opt['baseurl']:
         raise django.core.management.base.CommandError(
             '--root and --baseurl are mutually exclusive')
     if not (opt['root'] or opt['baseurl']):
         raise django.core.management.base.CommandError(
             'Must specify --root or --baseurl')
     if not (opt['element']):
         raise django.core.management.base.CommandError(
             'Must specify at least one element to copy')
     try:
         self._handle(opt)
     except d1_common.types.exceptions.DataONEException as e:
         raise django.core.management.base.CommandError(str(e))