Пример #1
0
 def connect_config_device():
     from common import config
     config = config.Config()
     device_name = config.get_config(config.TITLE_DEVICE,
                                     config.VALUE_DEVICE_NAME)
     L.i('connect_config_device %s ' % device_name, tag=TAG)
     ADB(device_name).connect()
Пример #2
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.cur_dir = os.path.abspath(os.getcwd())
     self.cur_dir = config.Config().get('cur_dir', self.cur_dir)
     self.register_event_type('on_dir_press')
     self.register_event_type('on_dir_select_changed')
     self.change_dir(self.cur_dir)
     self.select_set = set()
Пример #3
0
def get_all_magnet(code):
    # code=urllib.quote_plus(code)
    global URIBASE
    cur_url = config.Config().get('cur_url')
    if not config.Config().get('cur_url'):
        cur_url = get_cur_uri()
        config.Config().set_val('cur_url', cur_url)

    URIBASE = cur_url[len('https://'):]
    try:
        ret = _get_all_magnet(code)
        return ret
    except:
        cur_url = get_cur_uri()
        config.Config().set_val('cur_url', cur_url)
        URIBASE = cur_url[len('https://'):]
        return _get_all_magnet(code)
Пример #4
0
    def parse_config(self):

        self.cfg = config.Config(file(self.config_filename))

        if self.cfg.console.enable_input:
            self.daemonize = False

        self.root_dir = self.cfg.daemon.root_dir
        self.pid_file = self.cfg.daemon.pid_file
        self.uid = self.cfg.daemon.uid
        self.gid = self.cfg.daemon.gid

        self.log_file = self.cfg.logging.location
Пример #5
0
    def init(self):
        configdir_found = False
        for dir in install_datadir:
            path = os.path.join(dir, 'conf', 'host.conf')
            if os.path.exists(path):
                configdir_found = True
                break

        if not configdir_found:
            logger.error("Don't find the configuration dir.")
            sys.exit(1)

        p = pipe.Pipe()

        conf = config.Config(dir)
        config.set_conf_instance(conf)

        # Create mapping file handle
        mapping_file.set_mapping_file_handle(mapping_file.MappingFileHandle(dir))

        pdu_device = conf.pdu_name
        if pdu_device == "":
            logger.error("Not found pdu device in config file.")
            sys.exit(1)

        db_type = conf.db_type
        # Create OID handler
        if db_type == "SQLITE":
            oid_handler = SqliteOIDHandler()
        elif db_type == "WRITECACHE":
            oid_handler = FileOIDHandler()
        else:
            logger.error("DB type {} is not supported!".format(db_type))
            sys.exit(1)

        # Create VM handler
        vm_handler = VMwareHandler()

        # Create vPDU instance.
        if pdu_device == "SENTRY":
            self.__vpdu_handler = vsentry.vSentry(oid_handler, vm_handler, p)
        else:
            self.__vpdu_handler = vipiapp.vIPIAppliance(oid_handler, vm_handler, p)

        # Create SNMP simulator service
        self.__snmp_sim_serv = SNMPSimService()
Пример #6
0
    def change_dir(self, new_dir):
        try:
            self.file_data_dict = {}
            for index, i in enumerate(os.listdir(new_dir)):
                self.file_data_dict[i] = DirPathData(i, index)

            print(self.file_data_dict)

            _data = [None] * len(self.file_data_dict)
            for v in self.file_data_dict.values():
                _data[v.index] = v.to_dict()

            self.data = _data
            self.cur_dir = new_dir
            self.select_set = set()
            if self.parent:
                self.parent.dispatch('on_all_path_deselect')
            config.Config().set_val('cur_dir', self.cur_dir)
        except Exception as e:
            print(e)
Пример #7
0
def lambda_handler(event, context):
    import config

    cfg = new config.Config()
    print cfg.get('any')
    
    s3 = boto3.client('s3')

    arrived_file = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'])  #'csv-files/test2.csv'
    
    dir = send2dir(arrived_file)

    new_name = env + '/csv_files_raw/' + dir + '/' + arrived_file.split('/')[-1]
    print 'Copying {} to {} ...'.format(arrived_file, new_name)

    copy_source = {'Bucket': bk, 'Key': arrived_file}
    s3.copy_object(CopySource = copy_source, Bucket = bk, Key = new_name)

    return {
        "statusCode": 200,
        "body": json.dumps('in there!!!, event=' + str(event) + 'cfg->' + cfg.get('any'))
    }
Пример #8
0
##

import os
import logging
import locale
import gi
import uuid

from common import config
import nbxmpp
from common import defs
from common import ged as ged_module

interface = None  # The actual interface (the gtk one for the moment)
thread_interface = None  # Interface to run a thread and then a callback
config = config.Config()
version = config.get('version')
connections = {}  # 'account name': 'account (connection.Connection) instance'
ipython_window = None

ged = ged_module.GlobalEventsDispatcher()  # Global Events Dispatcher
nec = None  # Network Events Controller
plugin_manager = None  # Plugins Manager

log = logging.getLogger('gajim')

logger = None

from common import configpaths
gajimpaths = configpaths.gajimpaths
Пример #9
0
        self.add_widget(self.bottom_bar)

    def on_all_path_deselect(self):
        if self.bottom_bar:
            self.remove_widget(self.bottom_bar)
            self.bottom_bar = None

    def on_remove_press(self):
        self.ids['dir_view'].do_remove()

    def on_encrypt_press(self):
        self.ids['dir_view'].do_encrypt()

    def on_decrypt_press(self):
        self.ids['dir_view'].do_decrypt()

    def on_full_press(self):
        self.ids['dir_view'].do_full()


class MagToolApp(App):
    def build(self):
        return MainView()


if __name__ == '__main__':
    config.Config('EncryptTool')
    MagToolApp().run()
    # from lib import utils
    # utils.decrypt_file(r'E:\svn\Dev\xzj_win64_dev\xzj.exe')
Пример #10
0
def get_cfg(default_initfile, system_initfile, user_initfile):
    """return command lines and configuration files options"""

    cfg = config.Config()

    cfg.read_configfile(default_initfile)
    cfg.read_optional_configfiles([system_initfile, user_initfile])

    cfg.add_arg(
        'pathname', str, 1,
        'input file or directory (substituted by - for using pipe input)')
    #cfg.add_valu('-v','--version',int,3,'assign three version numbers to the file','NUMBER','FILE','version')
    #cfg.add_valu('-e','--edit',bool,1,'define if the file need to be edited or not','yes/no','FILE','edit')
    #cfg.add_negative_flag('-u','--unsafe','disable the safety','FILE','safety')

    cfg.add_choice('-o', '--mode', str, 1, ('check', 'return', 'write'),
                   'can choose mode: check, return or write', 'APPLICATION',
                   'mode')
    cfg.add_valu('-sc', '--sp_conv', str, 1,
                 'replace special characters by something else', 'STRING',
                 'APPLICATION', 'sp_conv')

    cfg.add_positive_flag(
        '-A', '--dir_ascii',
        'not allow accented characters in directories names', 'DIRECTORIES',
        'ascii')
    cfg.add_positive_flag('-B', '--dir_spaces',
                          'allow space in directories names', 'DIRECTORIES',
                          'spaces')
    cfg.add_valu(
        '-C', '--dir_case', int, 1,
        'switch directories characters names case (1=upper,-1=lower,0=no change)',
        'NUMBER', 'DIRECTORIES', 'case')
    cfg.add_valu(
        '-E', '--dir_ext', int, 1,
        'maximum numbers of .ext next to directories names ( -1 any )',
        'NUMBER', 'DIRECTORIES', 'ext')
    cfg.add_valu(
        '-M', '--dir_merge', str, 1,
        'merge duplicates characters in directories names (ex: -- becomes -)',
        'STRING', 'DIRECTORIES', 'merge')
    cfg.add_valu('-D', '--dir_eraze', str, 1,
                 'delete specified characters in the directories names',
                 'STRING', 'DIRECTORIES', 'eraze')
    cfg.add_valu(
        '-S', '--dir_strip', str, 1,
        'remove characters at the beginning or end of directories names',
        'STRING', 'DIRECTORIES', 'strip')
    cfg.add_valu('-R', '--dir_conv', str, 1,
                 'replace characters or strings in directories names',
                 'STRING', 'DIRECTORIES', 'conv')
    cfg.add_valu(
        '-RE', '--dir_conv_ext', str, 1,
        'replace characters or strings in directories names extensions',
        'STRING', 'DIRECTORIES', 'conv_ext')

    cfg.add_positive_flag('-a', '--ascii',
                          'not allow accented characters in files names',
                          'FILES', 'ascii')
    cfg.add_positive_flag('-b', '--spaces', 'allow space in files names',
                          'FILES', 'spaces')
    cfg.add_valu(
        '-c', '--case', int, 1,
        'switch files characters names case (1=upper,-1=lower,0=no change)',
        'NUMBER', 'FILES', 'case')
    cfg.add_valu('-e', '--ext', int, 1,
                 'maximum numbers of .ext next to files names ( -1 any )',
                 'NUMBER', 'FILES', 'ext')
    cfg.add_valu(
        '-m', '--merge', str, 1,
        'merge duplicates characters in files names (ex: -- becomes -)',
        'STRING', 'FILES', 'merge')
    cfg.add_valu('-d', '--eraze', str, 1,
                 'delete specified characters in the files names', 'STRING',
                 'FILES', 'eraze')
    cfg.add_valu('-s', '--strip', str, 1,
                 'remove characters at the beginning or end of files names',
                 'STRING', 'FILES', 'strip')
    cfg.add_valu('-r', '--conv', str, 1,
                 'replace characters or strings in files names', 'STRING',
                 'FILES', 'conv')
    cfg.add_valu('-re', '--conv_ext', str, 1,
                 'replace characters or strings in files names extensions',
                 'STRING', 'FILES', 'conv_ext')

    cfg.add_positive_flag('-l', '--local',
                          'will not create files outside program directory',
                          'SYSTEM', 'local')

    cfg.add_choice('-fv', '--logfile_verbosity', int, 1, (0, 1, 2, 3, 4, 5),
                   'logfile output verbosity level', 'VERBOSITY', 'logfile')
    cfg.add_choice('-tv', '--terminal_verbosity', int, 1, (0, 1, 2, 3, 4, 5),
                   'terminal output verbosity level', 'VERBOSITY', 'terminal')
    cfg.add_choice('-sv', '--syslog_verbosity', int, 1, (0, 1, 2, 3, 4, 5),
                   'syslog output verbosity level', 'VERBOSITY', 'syslog')

    ### os.path.isfile os.path.isdir etc can be use for check if filepath exist
    ### but we will have to check their existence again later, before starting to use them
    ### because in the meantime they can be changed / removed

    return cfg.get()
Пример #11
0
import traceback
import boto3
from botocore.exceptions import ClientError
from common.logs import Log
from common import config
from oauth.auth.scope.base import Base
common = config.Config()
log = Log()

acl_action_order = common.acl_action_order
acl_action_endpoint = common.acl_action_endpoint
acl_action_http_method = common.acl_action_http_method
acl_action_key = common.acl_action_key
event_resources_access_key = common.event_resources_access_key
acl_action_display_key = common.acl_action_display_key
grant_access_key = "grant-access"

if config.env != "dev":
    dynamodb = boto3.resource('dynamodb')
    scope_table = dynamodb.Table('scope')
    employee_role_scope_table = dynamodb.Table('employee_roles')
    role_scopes_table = dynamodb.Table('role_scopes')


class DynamoDB(Base):
    def __init__(self):
        self._emp_email_id = None
        self._emp_roles = None
        self._emp_allowed_event_resource_access = None
        self._emp_blocked_scope = None
        self._emp_blocked_grant_scope = None
Пример #12
0
 def parse_config(self):
     self.cfg = config.Config(file(self.file_config))
Пример #13
0
 def reload_config(self):
     self.cfg = config.Config(file(self.config_file))
     return self.config_file