Esempio n. 1
0
 def __init__(self):
     self.lat = Config().get()['Position']['Latitude']
     self.lng = Config().get()['Position']['Longitude']
     self.url = "https://api.sunrise-sunset.org/json?lat=%s&lng=%s&date=%s&formatted=0"
     self.data = None
     self.cacheKey = None
     self.fetch()
Esempio n. 2
0
 def update(self, update, context):
     import subprocess
     import sys
     subprocess.Popen(
         "sleep 5 && sh %s &> %s" % (Config().get()['Updater']['Path'],
                                     Config().get()['Logger']['Path']),
         shell=True)
     sys.exit(0)
Esempio n. 3
0
    def sendLatest(self, chat_id):
        latest = self.Capture()

        path = '%s%s_c%s_02%s' % (
            Config().get()["MotionDetector"]["Folder"], "latest", 0,
            Config().get()["MotionDetector"]["Extension"])
        Logger().logger.info(path)
        cv2.imwrite(path, latest)
        FeroxBot().sendImage(path, chat_id)
Esempio n. 4
0
def run(plugin_list: bool, plugins: str):
    """
        Version 3.0 work in progress
    """

    config = Config()

    if plugin_list:
        pluginManager = PluginManager()
        pluginManager.print_plugins_list()
        exit(0)

    if plugins is not None:
        plugins = PluginManager(plugins)
        print("Loaded : {0} plugins".format(plugins.plugin_loaded()))

        # todo load data dataDriver file.json or mongo

        # check if app running in docker environment and run server or client code
        if config.docker_mode:
            if os.environ.get("IS_SERVER"):
                # run server mode
                server = Server()
            else:
                # run client mode
                client = Client()
        exit(0)

    print("No arg detected :/")
    print("Please run 'python3 Toudoum.py run --help'")
Esempio n. 5
0
def main():

    config = Config()

    print(config.fsqlite, config.bearer)
    #sys.exit(1)

    HttpParser(config)
def main(_):
    assert len(sys.argv) == 2 or len(
        sys.argv) == 3, "usage: main.py <config> <optional_config_string>"
    config_path = sys.argv[1]
    assert os.path.exists(config_path), config_path
    try:
        if len(sys.argv) == 3:
            config = Config(config_path, sys.argv[2])
        else:
            config = Config(config_path)
    except ValueError as e:
        print("Malformed config file:", e)
        return -1
    init_log(config)
    # dump the config into the log
    print(open(config_path).read(), file=log.v4)
    engine = Engine(config)
    engine.run()
Esempio n. 7
0
 def test_config(self):
     """
     Test Config object
     """
     print("Start test of Config class...")
     c = Config('MSF21ADT', 'AMPSTC21ADT', 'CIM_2_NSTMMC21_AMPSTCADT')
     c.set_derived_val('NSTMMC21_MSFADT_VALID_2_MAP',
                       'NSTMMC21_MSFADT_MAP_2_CIM', 'NSTMMC21')
     data = vars(c)
     result = len(data)
     self.assertEqual(result, 6)
     self.assertDictEqual(data, self.cfgdict)
Esempio n. 8
0
    def __init__(self):
        self.client = pymongo.MongoClient(Config().get()['MongoDB']['URL'])

        if "ferox" not in self.client.list_database_names():
            raise Exception("database ferox not found")

        self.ferox = self.client["ferox"]

        if "chats" not in self.ferox.list_collection_names():
            raise Exception("database ferox not found")

        self.chats = self.ferox["chats"]
Esempio n. 9
0
    def __init__(self):
        filename = Config().get()['Logger']['Path']

        if (filename == "None"):
            filename = None

        logging.basicConfig(
            level=logging.CRITICAL,
            filename=filename,
            format='[%(asctime)s]: %(levelname)s - %(message)s')

        self.logger = logging.getLogger()
        self.logger.setLevel(logging.INFO)
Esempio n. 10
0
def main(_):
    assert len(sys.argv) == 2, "usage: main.py <config>"
    config_path = sys.argv[1]
    assert os.path.exists(config_path), config_path
    try:
        config = Config(config_path)
    except ValueError as e:
        print("Malformed config file:", e)
        return -1
    init_log(config)
    # dump the config into the log
    print(open(config_path).read(), file=log.v4)
    engine = EvalPascalRecursive(config)
    engine.run()
Esempio n. 11
0
 def test_flows(self):
     """
     Test Flows object
     """
     print("Start test of Flows class...")
     c = Config('MSF21ADT', 'AMPSTC21ADT', 'CIM_2_NSTMMC21_AMPSTCADT')
     c.set_derived_val('NSTMMC21_MSFADT_VALID_2_MAP',
                       'NSTMMC21_MSFADT_MAP_2_CIM', 'NSTMMC21')
     flow = Flows(c.dstFlowName,
                  FlowType.VF,
                  vars(c),
                  patternType=PatternType.AMP)
     data = vars(flow)
     #result = len(data)
     #self.assertEqual(result, 6)
     self.assertDictEqual(data, self.flowdict)
Esempio n. 12
0
    def __init__(self):
        self.updater = Updater(token=Config().get()["Telegram"]["Token"],
                               use_context=True)
        self.dispatcher = dispatcher = self.updater.dispatcher

        dispatcher.add_handler(CommandHandler('subscribe', self.subscribe))
        dispatcher.add_handler(CommandHandler('unsubscribe', self.unsubscribe))

        dispatcher.add_handler(CommandHandler('start', self.start))
        dispatcher.add_handler(CommandHandler('stop', self.stop))
        dispatcher.add_handler(CommandHandler('status', self.status))
        dispatcher.add_handler(CommandHandler('latest', self.latest))

        dispatcher.add_handler(CommandHandler('sun', self.sun))
        dispatcher.add_handler(CommandHandler('day', self.day))
        dispatcher.add_handler(CommandHandler('cache', self.cache))

        dispatcher.add_handler(CommandHandler('help', self.help))
        dispatcher.add_handler(CommandHandler('update', self.update))
Esempio n. 13
0
 def setUp(self):
     self.config = Config('config.json')
Esempio n. 14
0
from core.Config import Config
from core.Flows import FlowType, PatternType, Flows

c = Config('MSF21ADT', 'AMPSTC21ADT', 'CIM_2_NSTMMC21_AMPSTCADT')
c.set_derived_val('NSTMMC21_MSFADT_VALID_2_MAP', 'NSTMMC21_MSFADT_MAP_2_CIM',
                  'NSTMMC21')
#c.display()
print(" - Config Vars   - ")
print(vars(c))

flow = Flows(c.dstFlowName, FlowType.VF, vars(c), patternType=PatternType.AMP)
print(" - Flow Vars   - ")
print(vars(flow))
Esempio n. 15
0
 async def setUp(self):
     self.config = Config("../config.json", False)
     self.ticket = await Api.get_ticket(self.config.account,
                                        self.config.password)
Esempio n. 16
0
#!/usr/bin/python3

import os
import aiohttp, asyncio
import requests
import aiohttp
import json

from core.Config import Config as Config
from core.HTTPClient import HTTPClient

import binascii

PROJECT_ROOT = os.path.dirname(__file__)+'/'
cfg = Config(PROJECT_ROOT+'/config.json', False)

server = "{}://{}:{}".format(cfg.webserver['protocol'], cfg.webserver['host'], cfg.webserver['port'])



# don't do thix, use new http module!
async def send_get_request(endpoint):
    headers = {"secret": str(cfg.webserver["secret"]), "content_type": "application/json"}
    resp = await HTTPClient.get(endpoint, headers)
    
    print (str(resp))
    
async def send_post_request(endpoint, data={}, headers = {'secret': cfg.webserver['secret']}):
    response = requests.post(endpoint, data=data, headers=headers)
    resp = response.content.decode('utf-8')
    print (str(resp))
Esempio n. 17
0
#!/usr/bin/env python3

import os

from core.OpCodeHandler import OpCodeHandler as Client
from core.Config import Config as Config
from core.Plugin_Loader import Plugin_Loader

from webserver.Webserver import Webserver

PROJECT_ROOT = os.path.dirname(__file__) + '/'

config = Config(PROJECT_ROOT + '/config.json')

client = Client(config, PROJECT_ROOT + '/data/')
client.set_plugin_loader(Plugin_Loader(PROJECT_ROOT + '/plugins/'))
client.load_plugins()
#client._set_save_path(PROJECT_ROOT+'/data/')
#client.add_config(config)!
# start webserver in thread
Webserver(client)

# forever!
client.start()
Esempio n. 18
0
 def __init__(self):
     self.bot = telegram.Bot(Config().get()["Telegram"]["Token"])
Esempio n. 19
0
    def __init__(self, handler):
        self.folder = Config().get()["MotionDetector"]["Folder"]
        self.extension = Config().get()["MotionDetector"]["Extension"]
        self.handler = handler

        self.cam = Camera()
from core.Args import Args
from core.BackupFiles import BackupFiles
from core.Config import Config

if __name__ == '__main__':

    #Get the command lines arguments by initializing its class
    args = Args()
    config_file = args.get_config_file_arg()
    backup_path = args.get_backupdest_arg()
    file_name_add = args.get_add_file_arg()
    file_desc = args.get_file_desc_arg()
    file_name_rm = args.get_remove_file_arg()
    config_file_name = args.get_list_config_arg()

    #verify which argument has passed on cli to call the related method
    #a file is been added to config_file?
    if file_name_add:
        Config(config_file).add_config(file_name_add, file_desc)
    #a file is been removed from config_file?
    elif file_name_rm:
        Config(config_file).remove_config(file_name_rm)
    #user is listing files in config_file?
    elif config_file_name:
        Config(config_file).list_config(config_file_name)
    else:
        #backup files
        bkp = BackupFiles(config_file)
        #execute main program functionality - Make a backup
        bkp.execute_backup(backup_path)
Esempio n. 21
0
        # todo load data dataDriver file.json or mongo

        # check if app running in docker environment and run server or client code
        if config.docker_mode:
            if os.environ.get("IS_SERVER"):
                # run server mode
                server = Server()
            else:
                # run client mode
                client = Client()
        exit(0)

    print("No arg detected :/")
    print("Please run 'python3 Toudoum.py run --help'")


if __name__ == '__main__':
    click.clear()
    console.banner()
    load_dotenv(".env")
    if os.environ.get("APP_VERSION") is None:
        print("Error no environments file found :/")
        exit(1)

    if os.getuid() == 0:  # todo patch here for check windows admin
        config = Config()
        config.load()
        cli()
    else:
        console.error("You need to be run this script with root privileges")
        exit(1)
Esempio n. 22
0
 def __init__(self):
     # Load config for defaults & key
     self.config_manager = Config().get_instance()
     self.api_key = self.config_manager.get_api_key()
     self.logger = Logger()