当前位置: 首页>>代码示例>>Python>>正文


Python DITICConfig.get_system方法代码示例

本文整理汇总了Python中ditic_kanban.config.DITICConfig.get_system方法的典型用法代码示例。如果您正苦于以下问题:Python DITICConfig.get_system方法的具体用法?Python DITICConfig.get_system怎么用?Python DITICConfig.get_system使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ditic_kanban.config.DITICConfig的用法示例。


在下文中一共展示了DITICConfig.get_system方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_summary_file

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
def generate_summary_file():
    """
    We need this function in order to test the real generate_summary_file function. Its name has been changed to __...
    :return: the time necessary to execute this function
    """
    start_time = time()

    # Read configuration
    config = DITICConfig()

    # List of emails
    list_emails = set(config.get_email_to_user().keys())

    # List of possible status
    list_status = config.get_list_status()

    # Let use system config list
    system = config.get_system()

    rt_object = RTApi(system['server'], system['username'], system['password'])

    summary = __generate_summary_file(rt_object, list_emails, list_status)

    # The summary of all files will be flushed to this file.
    try:
        with open(summary_filename(system['working_dir'], system['summary_file']), 'w') as file_handler:
            dump(summary, file_handler)
    except IOError as e:
        raise IOError('Error:' + str(e))

    return '%0.2f seconds' % (time() - start_time)
开发者ID:tomascarvalho,项目名称:ES,代码行数:33,代码来源:rt_summary.py

示例2: test_get_system

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
def test_get_system():
    test_config = DITICConfig()
    test_config.system = {
        'server': 'server_address',
        'username': 'username',
    }
    response = test_config.get_system()
    assert response == {
        'server': 'server_address',
        'username': 'username',
    }
开发者ID:tomascarvalho,项目名称:ES,代码行数:13,代码来源:test_config.py

示例3: get_summary_info

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
def get_summary_info():
    """
    returns a dictionary with the following format
        {
            'email':
                {
                    'status': 'value',
                    ...
                }
            ...
        }
    :return:
    """
    #generate_summary_file() #retirar o comando generate_summary_file
    #stats_update_json_file() # retirar o comando update_statistics



    # Read configuration
    config = DITICConfig()

    # List of known emails
    list_emails = config.get_email_to_user().keys()

    # List of known status
    list_status = config.get_list_status()

    # Let use system config list
    system = config.get_system()

    # Get the file information
    try:
        with open(summary_filename(system['working_dir'], system['summary_file']), 'r') as file_handler:
            summary = load(file_handler)
    except IOError:
        # If there is an error, then return everything zeroed
        summary = {email: {status: 0 for status in list_status} for email in list_emails}
        summary['dir'] = {status: 0 for status in list_status}
        summary['dir-inbox'] = {status: 0 for status in list_status}
        summary['unknown'] = {status: 0 for status in list_status}

    return summary
开发者ID:tomascarvalho,项目名称:ES,代码行数:44,代码来源:rt_summary.py

示例4: stats_update_json_file

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
def stats_update_json_file(number_of_days=1):
    """
    Reads old json file, if it exists, get new information, update statistics, write back to file
    There is a known bug: the number_of_days MUST not overlap a month If it does, there will be a problem ;)

    :param number_of_days: Number of days to analyze
    :return: time took to execute
    """
    # TODO: guarantee that the data is written in the correct filename, if number_of_days overlap a month
    start_time = time()

    config = DITICConfig()
    system = config.get_system()
    rt_object = RTApi(system['server'], system['username'], system['password'])

    # result = read_statistics_file(config)
    for this_day in range(0, number_of_days):
        current_date = get_date(this_day)
        current_year_month = current_date[:7]
        result = stats_read_json_file(current_year_month[:4], current_year_month[5:7])
        result[get_date(this_day)] = full_list_of_tickets_on_a_date(rt_object, config, current_date)
        write_statistics_file(config, result, current_year_month[:4], current_year_month[5:7])

    return '%0.2f seconds' % (time() - start_time)
开发者ID:FranciscoMSM,项目名称:ES,代码行数:26,代码来源:statistics.py

示例5: UserAuth

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
from ditic_kanban.tools import archive_tickets
from ditic_kanban.rt_api import RTApi
from ditic_kanban.rt_api import get_list_of_tickets
from ditic_kanban.rt_api import modify_ticket
from ditic_kanban.statistics import get_date
from ditic_kanban.statistics import get_statistics
from subprocess import call

emailGlobal = ''

# My first global variable...
user_auth = UserAuth()

# Only used by the URGENT tickets search
my_config = DITICConfig()
system = my_config.get_system()
rt_object = RTApi(system['server'], system['username'], system['password'])

# This part is necessary in order to get access to sound files
# Static dir is in the parent directory
STATIC_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../static"))

print STATIC_PATH

@get('/static/<filename>')
def fileget(filename):
    return static_file(filename, root='views')

@route('/getUrgentNumber')
def get_urgent_number():
    return str(len(get_urgent_tickets(rt_object)))
开发者ID:FranciscoMSM,项目名称:ES,代码行数:33,代码来源:server.py

示例6: DITICConfig

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
#!/usr/bin/env python
from pprint import pprint

from ditic_kanban.config import DITICConfig
from ditic_kanban.rt_api import RTApi
#from ditic_kanban.statistics import stats_read_json_file
#from ditic_kanban.statistics import get_statistics
#from ditic_kanban.statistics import full_list_of_tickets_on_a_date
from ditic_kanban.rt_projects import get_project_tree
from ditic_kanban.rt_projects import ManageProjectElements

config = DITICConfig()
system = config.get_system()
rt_object = RTApi(system['server'], system['username'], system['password'])

#for aux in range(0, 30):
#    print get_date(aux),
#    print stats_number_of_tickets_of_an_user(rt_object, '[email protected]', get_date(aux))
#print stats_update_json_file(28)
#result = stats_read_json_file('2015', '07')
#for day in sorted(result):
#    print day,
#    print 'Created:', result[day]['created_tickets'],
#    print 'Resolved:', result[day]['team']['resolved'],
#    print 'Open:', result[day]['team']['open']
#    print 'Mean time: %0.2f' % result[day]['team']['mean_time_to_resolve']
#pprint(get_statistics('2015-05-01', '2015-07-30'))
#result = full_list_of_tickets_on_a_date(rt_object, config, '2015-07-25')
#pprint(result)

# Project examples:
开发者ID:tomascarvalho,项目名称:ES,代码行数:33,代码来源:tests.py

示例7: __init__

# 需要导入模块: from ditic_kanban.config import DITICConfig [as 别名]
# 或者: from ditic_kanban.config.DITICConfig import get_system [as 别名]
class UserAuth:
    
    def __init__(self):
        self.config = DITICConfig()
        self.ids = {
            # Only used for tests...
            # u'10': {
            #     'email': '[email protected]',
            #     'rt_object':  RTApi('server_address', 'username', 'password'),
            # }
        }

    def __get_new_id(self):
        while True:
            new_id = unicode(randint(0, 1000))
            if new_id not in self.ids:
                return new_id

    # noinspection PyTypeChecker
    def get_email_id(self, email):
        if email not in self.config.get_email_to_user().keys():
            raise ValueError('Unknown email')

        for uid in self.ids:
            if email == self.ids[uid]['email']:
                return uid

        raise ValueError('Unknown error! This should not be like this...')

    # noinspection PyTypeChecker
    def get_email_from_id(self, uid):
        if 'email' not in self.ids[uid]:
            raise ValueError('Unauthenticated user')
        return self.ids[uid]['email']

    # noinspection PyTypeChecker,PyTypeChecker
    def get_rt_object_from_email(self, email):
        if email not in self.config.get_email_to_user().keys():
            raise ValueError('Unknown email')

        for uid in self.ids:
            if email == self.ids[uid]['email']:
                return self.ids[uid]['rt_object']

        raise ValueError('Unknown error! This should not be like this...')

    def check_id(self, uid):
        """
        This function will check if id exists.
        It is important to say that id MUST be a unicode value!

        :param uid: unicode with id value
        :return: True or False, depending if ID exists or not
        """
        if uid in self.ids:
            return True
        return False

    def check_password(self, email, pwd):
        if email not in self.config.get_email_to_user().keys():
            raise ValueError('Unknown email')

        # Get system configurations
        system = self.config.get_system()

        # To check the password, we will try to check if user has any new ticket
        email_rt_api = RTApi(system['server'], email, pwd)

        data_dict = {'query': 'Owner = "%s" and Status = "new"' % email}
        response = email_rt_api.get_data_from_rest('/search/ticket', data_dict)
        if 'your username or password is incorrect' in response:
            raise ValueError('Password is incorrect')

        self.ids[self.__get_new_id()] = {
            'email': email,
            'rt_object': email_rt_api,
        }
        return True
开发者ID:tomascarvalho,项目名称:ES,代码行数:80,代码来源:auth.py


注:本文中的ditic_kanban.config.DITICConfig.get_system方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。