Ejemplo n.º 1
0
class Setup(object):
    """
        Used to setup the script (fill configuration settings)
    """
    def __init__(self, log, app_config):
        mypath = expanduser('~') + '/.jav/'
        onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
        only_ymls = [
            f for f in onlyfiles
            if f.startswith('config_') and f.endswith('.yml')
        ]

        for single_config in only_ymls:
            self.log = log
            self.config = Config(self.log, config_filename=single_config)
            self.log_config = LogConfig(self.log, app_config,
                                        self.config.config_path + 'setup.log')

    def main(self):
        self.log.info('Initiating App Setup')

        # If conf init was called when Config class was initialized, then we don't call it again
        # This would happen if setup is called before a config file was created
        if self.config.config_init is False:
            self.config.init_config()
Ejemplo n.º 2
0
    def test_get_config_value(self):
        """Receives a parameter and test if a value can be returned"""
        # App init, necessary to get to the logging service
        app = self.get_app()
        config = Config(app.log, config_values=self.get_config())

        self.assertEqual(config.get_config_value('jira_jql_remaining'),
                         'JQL QUERY')
Ejemplo n.º 3
0
    def __init__(self, log, app_config):
        mypath = expanduser('~') + '/.jav/'
        onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
        only_ymls = [
            f for f in onlyfiles
            if f.startswith('config_') and f.endswith('.yml')
        ]

        for single_config in only_ymls:
            self.log = log
            self.config = Config(self.log, config_filename=single_config)
            self.log_config = LogConfig(self.log, app_config,
                                        self.config.config_path + 'setup.log')
Ejemplo n.º 4
0
    def test_set_config_value(self):
        """Modifies configuration of a parameter and check output"""
        # App init, necessary to get to the logging service
        app = self.get_app()
        config = Config(app.log, config_values=self.get_config())

        self.assertEqual(config.get_config_value('jira_jql_remaining'),
                         'JQL QUERY')
        self.assertEqual(
            config.set_config_value('jira_jql_remaining', 'NEW JQL QUERY'),
            'NEW JQL QUERY')
        self.assertEqual(config.get_config_value('jira_jql_remaining'),
                         'NEW JQL QUERY')
Ejemplo n.º 5
0
    def clear(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'clear.log')

        clear = Clear(self.app.log, config)
        clear.main()
Ejemplo n.º 6
0
    def load(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'load.log')

        load = Load(self.app.log, self.app.config)
        load.refresh_jira_cache()
Ejemplo n.º 7
0
    def run(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'run.log')

        # Load data from Jira
        load = Load(self.app.log, self.app.config)
        daily_data, remaining_work = load.refresh_jira_cache()

        # Crunch numbers
        crunch = Crunch(self.app.log, config)
        stats_days, stats_weeks, stats_remaining = crunch.crunch_stats(
            daily_data, remaining_work)

        # Build Chart
        BuildChart(self.app.log, config).main(stats_days, stats_weeks,
                                              stats_remaining)

        # Publish Chart
        PublishGithubPage(self.app.log, config).main()

        #Get previously crunched number from cache file, to avoid the issue with json index key conversion
        # Issue, there is no numerical indexes in json, only strings.
        stats_days, stats_weeks, stats_remaining = crunch.load_stats_cache()

        # Message Team
        Msg(self.app.log, config,
            self.app.pargs.send).publish(stats_days, stats_weeks,
                                         stats_remaining)
Ejemplo n.º 8
0
class Setup(object):
    """
        Used to setup the script (fill configuration settings)
    """
    def __init__(self, log, app_config):
        self.log = log
        self.config = Config(self.log)
        self.log_config = LogConfig(self.log, app_config,
                                    self.config.config_path + 'setup.log')

    def main(self):
        self.log.info('Initiating App Setup')

        # If conf init was called when Config class was initialized, then we don't call it again
        # This would happen if setup is called before a config file was created
        if self.config.config_init is False:
            self.config.init_config()
Ejemplo n.º 9
0
    def crunch(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'crunch.log')

        # Loading saved files into memory to be used by the component crunching numbers
        load = Load(self.app.log, self.app.config)
        daily_data, remaining_work = load.load_jira_cache()

        crunch = Crunch(self.app.log, config)
        crunch.crunch_stats(daily_data, remaining_work)
Ejemplo n.º 10
0
    def msg(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'msg.log')

        #Get previously crunched number from cache file
        crunch = Crunch(self.app.log, config)
        stats_days, stats_weeks, stats_remaining = crunch.load_stats_cache()

        Msg(self.app.log, config,
            self.app.pargs.send).publish(stats_days, stats_weeks,
                                         stats_remaining)
Ejemplo n.º 11
0
    def chart(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'chart.log')

        #Get previously crunched number from cache file
        crunch = Crunch(self.app.log, config)
        stats_days, stats_weeks, stats_remaining = crunch.load_stats_cache()

        #Build charts
        BuildChart(self.app.log, config).main(stats_days, stats_weeks,
                                              stats_remaining)
Ejemplo n.º 12
0
 def test_init_config_auto(self):
     """Automatically initialize the default config"""
     # App init, necessary to get to the logging service
     app = self.get_app()
     config = Config(app.log, config_values=self.get_config())
     self.assertEqual(config.get_config_value('jira_jql_remaining'),
                      'JQL QUERY')
     config.init_config_auto()
     self.assertEqual(config.get_config_value('jira_jql_remaining'),
                      'JQL QUERY REMAINING')
Ejemplo n.º 13
0
    def publish(self):
        config = Config(self.app.log, self.app.pargs.path_config)
        LogConfig(self.app.log, self.app.config,
                  config.config_path + 'publish.log')

        PublishGithubPage(self.app.log, config).main()
Ejemplo n.º 14
0
 def __init__(self, log, app_config):
     self.log = log
     self.config = Config(self.log)
     self.time = Time(self.log, self.config)
     self.log_config = LogConfig(self.log, app_config,
                                 self.config.config_path + 'load.log')
Ejemplo n.º 15
0
 def __init__(self, log, app_config, single_config='config.yml'):
     self.log = log
     self.config = Config(self.log, config_filename=single_config)
     self.time = Time(self.log, self.config)
     self.log_config = LogConfig(self.log, app_config,
                                 self.config.config_path + 'load.log')
Ejemplo n.º 16
0
 def __init__(self, log, app_config):
     self.log = log
     self.config = Config(self.log)
     self.log_config = LogConfig(self.log, app_config,
                                 self.config.config_path + 'setup.log')