Ejemplo n.º 1
0
def asgard(ctx):
    '''
    Asgard -- A deploy tool bases on k8s ,helm and chartmuseum.
    Run `asgard init` first if this is your first time to use.
    '''
    cmd = ctx.invoked_subcommand
    keyword = 'helm'
    if cmd == 'init':
        return

    if not path.isfile(CONFIG_FILE):
        click.echo(click.style('Run init first', fg='red'))
        return

    cfg = profig.Config(CONFIG_FILE)
    cfg.sync()
    if cfg.section(keyword).get('chart_repo'):
        click.echo(
            click.style(
                'WARNING: the config `chart_repo` has been desperate!\n',
                fg='yellow'))

    if not environ.get('VIRTUAL_ENV'):
        click.echo(
            click.style('WARNING: You are using global settings!\n',
                        fg='yellow'))

    ctx.obj.update(cfg.section(keyword))
Ejemplo n.º 2
0
def init(ctx):
    '''
    Init and set asgard's config. Please run and follow it.
    '''
    cfg = profig.Config(CONFIG_FILE)
    cfg.sync()

    click.echo(click.style('Init Helm ...', fg='yellow'))
    helm.init('-c')
    click.echo(click.style('Init Helm [OK]', fg='green'))

    setting_key = 'helm.kube_context'
    kube_context = click.prompt('Please the name of your k8s context',
                                default=cfg.get(setting_key, ''))
    cfg[setting_key] = kube_context

    setting_key = 'helm.tiller_host'
    tiller_host = click.prompt('Please enter uri for tiller',
                               default=cfg.get(setting_key, ''))
    cfg[setting_key] = tiller_host

    setting_key = 'helm.tiller_namespace'
    tiller_namespace = click.prompt('Please enter namespace for tiller',
                                    default=cfg.get(setting_key, ''))
    cfg[setting_key] = tiller_namespace

    setting_key = 'helm.helm_repo'
    helm_repo = click.prompt('Please enter the default helm repo',
                             default=cfg.get(setting_key))
    cfg[setting_key] = helm_repo

    cfg.sync()
Ejemplo n.º 3
0
    def __init__(self,
                 path_to_conf: str = 'config.ini',

                 cli: bool = False,
                 header_dict: dict = None,
                 username: str = None,
                 password: str = None,
                 token: str = None,
                 item_id=None,
                 exclude_no=None,
                 sms_interval=None,
                 sms_wait_max=None,
                 mobile=None,
                 ):
        """
        KMA Service

        :param path_to_conf:
        :param cli:
        :param header_dict:
        :param username:
        :param password:
        :param token:
        :param item_id:
        :param exclude_no:
        :param sms_interval:
        :param sms_wait_max:
        :param mobile:
        """
        cfg = profig.Config(path_to_conf)
        cfg.init('sms_52kma.username', '')
        cfg.init('sms_52kma.password', '')
        cfg.init('sms_52kma.token', '')
        cfg.init('sms_52kma.item_id', '')
        cfg.init('sms_52kma.exclude_no', '')
        cfg.init('sms_52kma.sms_interval', 5)
        cfg.init('sms_52kma.sms_wait_max', 180)
        cfg.sync()

        self._base_url = 'http://api.fxhyd.cn/UserInterface.aspx'

        self._cli = cli

        self._header_dict = header_dict or {
            'User-Agent': os.getenv(
                'YM_USERAGENT',
                'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'),
        }

        self._username = username or cfg['sms_52kma.username']
        self._password = password or cfg['sms_52kma.password']
        self._token = token or cfg['sms_52kma.token'] or self._get_token()
        self._item_id = item_id or cfg['sms_52kma.item_id']
        self._exclude_no = exclude_no or cfg['sms_52kma.exclude_no']
        self._sms_interval = sms_interval or cfg['sms_52kma.sms_interval']
        self._sms_wait_max = sms_wait_max or cfg['sms_52kma.sms_wait_max']

        self._mobile = mobile
        pass
Ejemplo n.º 4
0
 def __init__(self, pth=None):
     self.pth = pth if pth else os.path.join(app_root, 'config/.crawl.cnf')
     self.cfg = profig.Config(self.pth, encoding='utf-8')
     self.cfg.read()
     self.init_type()
     if not os.path.exists(os.path.expanduser(self.pth)):
         self.cfg.sync()
         raise SystemExit('config file path not exists: {}'.format(
             os.path.expanduser(self.pth)))
Ejemplo n.º 5
0
    def __init__(self):
        cfgPath = os.path.join(sys.path[0], 'conf', 'init.cfg')
        config = profig.Config(cfgPath)
        config.read()

        self.doc_url = config.get('doc.url')
        self.doc_file = config.get('doc.file')
        self.doc_html = config.get('doc.html')

        print(
            '====> cfg load success, doc_url: %s,  doc_file : %s ,  doc_file : %s '
            % (self.doc_url, self.doc_file, self.doc_html))
Ejemplo n.º 6
0
    def __init__(self, commandline=False):
        """
        Initializes the options. Tries to read the configuration file,
        initializes defaults for all options, and updates the configuration
        file with missing options and documentation, if required.

        :param commandline: If ``True``, also parse the command line for option
            overrides using ``-O <option>:<value>``.
        """
        config = profig.Config("pydelta.ini")
        self.cfg = config
        self.initialize()
        if commandline:
            self.get_commandline()
Ejemplo n.º 7
0
class Config:
    PATH_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/"
    PATH_DATA = os.path.join(PATH_PROJECT_ROOT, "data/")

    _config_source = os.path.join(PATH_PROJECT_ROOT, "config.cfg")
    _instance = profig.Config(_config_source)
    _instance.sync(_config_source)

    CARTO_USER = _instance['carto.USER']
    CARTO_PASSWORD = _instance['carto.PASSWORD']
    CARTO_API_KEY = _instance['carto.API_KEY']

    @staticmethod
    def set_value(key, value):
        Config._instance[key] = value
        Config._instance.sync()
Ejemplo n.º 8
0
    def __init__(self, config_file, dat=None, enable_default_log=True):
        try:
            if not get_file_size(config_file):
                create_file(config_file)
            self._pth, t = os.path.split(config_file)
            self._cfg_name = t.split('.')[0]
        except Exception as _:
            self._pth = '/tmp'
            self._cfg_name = 'izen'

        self.cfg = profig.Config(config_file, encoding='utf-8')
        self.cfg.read()

        if enable_default_log:
            self.__spawn()

        if dat:
            self.__do_init(dat)

        if not os.path.exists(os.path.expanduser(config_file)):
            self.cfg.sync()
Ejemplo n.º 9
0
    def __init__(self, path_to_config: str = 'config.ini'):
        self._cfg = profig.Config(path_to_config)
        self._cfg.init('path.python', '/usr/bin/python3')
        self._cfg.init('path.python_ssr', '/data/repo/shadowsocksr/shadowsocks/local.py')
        self._cfg.init('path.proxychains4', '/usr/bin/proxychains4')
        self._cfg.init('ssr_utils.local_port', 13431)
        self._cfg.init('ssr_utils.path_to_pre_proxy', 'pre_proxy.txt')
        self._cfg.init('ssr_utils.proxychains4_cache_time', 300)
        self._cfg.sync()

        self._path_to_config = path_to_config

        self._server = None
        self._port = None
        self._method = None
        self._password = None
        self._protocol = None
        self._proto_param = None
        self._obfs = None
        self._obfs_param = None

        self._remarks = None
        self._group = None

        self._server_ip = None
        self._server_domain = None

        self._local_address = None
        self._local_port = None
        self._path_to_ssr_conf = None

        self._exit_ip = None

        self._cmd = None
        self._cmd_prefix = None
        self._sub_progress = None
        pass
Ejemplo n.º 10
0
    def __init__(self, pth, dat=None, enable_default_log=True):
        """初始化配置文件
        - 文件不存在: 将字典dat初始化到文件中
        - 文件存在: 以字典数据类型来初始化配置文件

        :param dat: ``字典类型``
        :type dat: dict
        :param pth: ``文件存储路径``
        :type pth: str
        :param enable_default_log: ``是否启用默认log配置参数``
        :type enable_default_log: bool
        """
        try:
            if not helper.is_file_ok(pth):
                helper.write_file('', pth)
            self._pth, t = os.path.split(pth)
            self._cfg_name = t.split('.')[0]
        except Exception as _:
            self._pth = '/tmp'
            self._cfg_name = 'izen'

        self.cfg = profig.Config(pth, encoding='utf-8')

        # 读取配置
        self.cfg.read()

        # 初始化默认log字段类型
        if enable_default_log:
            self.__spawn()

        # 初始化自定义字典
        if dat:
            self.__do_init(dat)

        # 在配置不存在时, 需要首先初始化在内存中, 然后再同步到本地并退出执行程序
        if not os.path.exists(os.path.expanduser(pth)):
            self.cfg.sync()
Ejemplo n.º 11
0
import sys
import signal

from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GObject
import dbus
import profig

APPNAME = "com.vhakulinen.push-notification"
INVOKED = "ActionInvoked"

BROWSER = "firefox"
TIMEOUT = 5
BUFSIZE = 1024

cfg = profig.Config("%s/.config/push-notify.conf" % os.getenv("HOME"))
cfg.sync()

HOST = cfg["default.host"]
PORT = int(cfg["default.port"])
ADDR = (HOST, PORT)
TOKEN = cfg["default.token"]

notification = None
url = ""
# Dirty hack around for multi triggered event problem
count = 0


class Receiver(threading.Thread):
    running = False
Ejemplo n.º 12
0
def initialize(config_pathname, flask_app):
    cfg = profig.Config(config_pathname)
    cfg.sync()
    params.update(cfg)
    params.update({FLASK_APP: flask_app})
Ejemplo n.º 13
0
    if 'gdax' in config_keys:
        gdaxPrivate = GDAXPrivate(config['gdax.key'], config['gdax.secret'],
                                  config['gdax.passphrase'])
        exchanges.append(gdaxPrivate)
    if 'kraken' in config_keys:
        kraken = Kraken(config['kraken.key'], config['kraken.secret'],
                        GDAXPublic())
        exchanges.append(kraken)
    if 'poloniex' in config_keys:
        poloniex = Poloniex(config['poloniex.key'], config['poloniex.secret'],
                            GDAXPublic())
        exchanges.append(poloniex)

    return exchanges


if __name__ == '__main__':
    config = profig.Config(CONFIG_FILE)
    config.sync()

    exchanges = init_exchanges(config)

    asset_sales, leftover_lots = calculate_gains_losses(exchanges)

    total_gain_loss = sum(sale.gain_loss for sale in asset_sales)
    print("total gains/loss:")
    print("{} USD".format(total_gain_loss))

    for lot in leftover_lots:
        print(lot.currency, lot.created_at, lot.amount, lot.price)
Ejemplo n.º 14
0
import questionary
from prettytable import PrettyTable
from redminelib import Redmine
from rich.columns import Columns
from rich.panel import Panel
from rich.markdown import Markdown

from redmine.utils import get_last_versions, gen_number_release, get_memberships, get_custom_fields, get_cf_values, \
    get_current_project_version, get_trackers_project, get_row_data, get_status_project, get_projects, \
    generate_versions, is_last_version_app
from redmine.tables import get_table_for_release, get_table_for_issues, get_table_for_versions, get_table

console = Console()
HOME_PATH = os.getenv('USERPROFILE')
CFG_PATH = os.path.join(HOME_PATH, '.redmine.cfg')
cfg = profig.Config(CFG_PATH, encoding='utf-8')

cfg.init('redmine.host', 'localhost')
cfg.init('redmine.username', '')
cfg.init('redmine.password', '')
cfg.init('redmine.token', '')
cfg.init('project.id', '')
cfg.init('release.tracker_id', 6, int)
cfg.init('release.subject', 'Релиз %s', str)
cfg.init('release.done_status_id', 12, int)
cfg.init('release.filter_custom_fields', [], list)
cfg.init('issue.filter_custom_fields', [], list)
cfg.init('user.me_query_id', 0, int)


def get_rd(cfg_data):
Ejemplo n.º 15
0
 def load(cls, config_pathname):
     cfg = profig.Config(config_pathname)
     cfg.sync()
     config = cls()
     config._params.update(cfg)
     return config
Ejemplo n.º 16
0
import profig

cfg = profig.Config('settings.cfg')


def init():
    global cfg

    # Settings
    cfg.init('server.host', 'localhost')
    cfg.init('server.port', '3468')
    cfg.init('server.user', 'admin')
    cfg.init('server.pass', 'password')

    cfg.init('radarr.apikey', '')
    cfg.init('radarr.url', 'http://localhost:7878')

    cfg.init('bot.debug_file', True)
    cfg.init('bot.debug_console', True)

    # Trackers
    cfg.init('iptorrents.nick', '')
    cfg.init('iptorrents.nick_pass', '')
    cfg.init('iptorrents.auth_key', '')
    cfg.init('iptorrents.torrent_pass', '')

    cfg.init('ptp.nick', '')
    cfg.init('ptp.site_username', '')
    cfg.init('ptp.nick_pass', '')
    cfg.init('ptp.auth_key', '')
    cfg.init('ptp.torrent_pass', '')
Ejemplo n.º 17
0
#!/usr/bin/env python
import socket
import profig

cfg = profig.Config("server.conf")
cfg.init("listen.host", "localhost")
cfg.init("listen.port", 22330)
cfg.sync()

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((cfg['listen.host'], cfg['listen.port']))
server.listen(2000)

print "Server running on {}:{}".format(cfg['listen.host'], cfg['listen.port'])

while True:
    connection, address = server.accept()
    print "Accepted connection from {}:{}".format(address[0], address[1])
    buff = connection.recv(50)
    if len(buff) > 0:
        print ">>"
        print len(buff)
        print buff
Ejemplo n.º 18
0
def initialize(config_pathname):
    cfg = profig.Config(config_pathname)
    cfg.sync()
    params.update(cfg)