Пример #1
0
    def save_fits(self, filename, fits):
        """ Save a collection of configured fits to YAML file.
            @param fits dict: dictionay with fits, function references and parameter objects

            @return dict: storable dictionary with fit description
        """
        stripped_fits = self.prepare_save_fits(fits)
        save(filename, stripped_fits)
Пример #2
0
def settings_handle():
    if request.method == 'GET':
        return jsonify({
            'data': config.dict(),
            'code': 20000
        })
    data = request.json
    settings = data['settings']
    config_dict = config.dict()
    for k, v in settings.items():
        if k in config_dict:
            config[k] = v
    config.save()
    return jsonify({'code': 20000})
Пример #3
0
for server_name in bot.config['servers']:
    server: Dict[str, Any] = bot.config['servers'][server_name]
    if server:
        client: Client = Client(server['nick'])
    else:
        print('Invalid server config.')
        sys.exit(0)

    bot.clients.append(client)
    pool.connect(client, server['server'], tls=True, tls_verify=False)

try:
    pool.handle_forever()
except KeyboardInterrupt:
    print('Disconnecting clients.')
    for client in bot.clients:
        pool.disconnect(client)
    print('Saving and closing dbs.')
    for conn in list(bot.dbs.values()):
        conn.commit()
        conn.close()
    print('Saving config.')
    config.save(bot)
    if restarted:
        print('Restarting.')
        args: List[str] = sys.argv[:]
        args.insert(0, sys.executable)
        os.execv(sys.executable, args)
    else:
        print('Closing.')
Пример #4
0
import os

from core import config
from core.notification.gmail import Gmail
from core.storage.google_drive import GoogleDrive

if __name__ == '__main__':
    items = os.listdir('.')
    if 'gmail_v1_token.json' not in items:
        Gmail().initialize_service()
    if 'drive_v3_token.json' not in items:
        gd = GoogleDrive()
        gd.initialize_service()
        if 'google_drive_folder_id' not in config.global_instance:
            folder_id = gd.create_folder('nico_crawler')
            config.save('config_secret.json',
                        kvps={'google_drive_folder_id': folder_id})
Пример #5
0
from core import config

if __name__ == '__main__':
    aws_region = input('aws_region:')
    aws_access_key_id = input('aws_access_key_id:')
    aws_secret_access_key = input('aws_secret_access_key:')

    kvps = {
        'aws_region': aws_region,
        'aws_access_key_id': aws_access_key_id,
        'aws_secret_access_key': aws_secret_access_key
    }

    config.save('config_secret.json', kvps)