Beispiel #1
0
    def test_5_log_file_exist(self):
        LogUtil.get_logger(app_name=self.APP_NAME)

        file_path = os.path.join(LogUtil.log_dir(app_name=self.APP_NAME),
                                 LogUtil.log_file())

        self.assertTrue(os.path.isfile(file_path), msg='is exist log file')
Beispiel #2
0
    def test_1_log_file(self):
        self.assertEqual(LogUtil.log_dir(app_name=self.APP_NAME),
                         'log/I_Love_Jellicle',
                         msg='Directory Verify')

        self.assertEqual(LogUtil.log_file(),
                         datetime.now().strftime('%Y-%m-%d.log'),
                         msg='File Name Verify')
Beispiel #3
0
    def start(self):
        # setting
        if is_file_exist(self.setting_file) is False:
            exit(1)

        setting = FileUtil.read_yml_file(self.setting_file)

        # arg
        args = self._arguments()

        # app
        try:
            app = ObjectUtil.get_class(
                module_name='%s.%s' %
                (setting['app_root'].replace('/', '.'), args['app'].lower()),
                class_name='APP')
        except KeyError:
            print('setting.yml[app_root] or arguments[app] is missing ...')
            app = None

        # validation
        if app is None:
            app_name = '%s-none' % setting['app_name']

            logger = LogUtil.get_logger(app_name=app_name)

            if args is None or len(args.keys()) == 0:
                app_name_for_log = setting['app_name']

            else:
                try:
                    app_name_for_log = args['app']
                except KeyError:
                    app_name_for_log = setting['app_name']

            logger.info('Not found "%s" application ... ' % app_name_for_log)

        else:
            app_name = '%s-%s' % (setting['app_name'], args['app'])

            logger = LogUtil.get_logger(app_name=app_name)

            logger.info('Execute "%s" application ... ' % args['app'])

            app(args=args, logger=logger, setting=setting).start()
Beispiel #4
0
    def __init__(self, app_name, user_name, credential_root, logger=None):
        self.logger = LogUtil.get_logger(
            app_name=app_name) if logger is None else logger

        self.service = CredentialManager(logger=self.logger).service(
            service_name=ServiceMap.SHEETS,
            app_name=app_name,
            user_name=user_name,
            credential_root=credential_root)
Beispiel #5
0
    def test_2_logger(self):
        logger = LogUtil.get_logger(app_name=self.APP_NAME)

        self.assertIn(logger.level, [logging.DEBUG, logging.INFO],
                      msg='Log Level')
        self.assertEqual(logger.name, 'yangs_util', msg='Log Name Verify')
Beispiel #6
0
 def __init__(self, logger=None):
     if logger is None:
         self.logger = LogUtil.get_logger(
             app_name='Google Credential Manager')
     else:
         self.logger = logger