Example #1
0
def main():
    """conf['image']['trackbars']"""

    scr = os.path.dirname(os.path.abspath(__file__))
    my_conf = MyConfig(scr + "/rezobox_server.ini")
    conf = my_conf.conf
    print("Configuration du serveur: {}\n".format(conf))

    disp = Display(my_conf)

    if not conf['image']['thread']:
        print('Test kinect sans thread')
        while 1:
            disp.one_loop()
    else:
        print('Test kinect avec thread')
        kinect_thread(disp)
Example #2
0
    def __init__(self, expn=None, exp_path=None, config=None, loglevel=log.NO):
        self.LOGLEVEL = loglevel

        myconfig = MyConfig()
        if expn is not None and exp_path is not None:
            self.EXPN = expn
            self.FOLDER = os.path.join(exp_path, str(expn))
            self.config = myconfig  #load_config(self.FOLDER)
            log.info(self.LOGLEVEL, "Load experiment #{}".format(self.EXPN))
        elif config is not None:
            self.config = config
            exp_path = os.path.join(self.config.ROOT_PATH,
                                    self.config.EXP_FOLDER)
            os.makedirs(exp_path, exist_ok=True)
            self.EXPN = 1 + len(utils.listdir(exp_path))
            self.FOLDER = os.path.join(self.config.ROOT_PATH,
                                       self.config.EXP_FOLDER, str(self.EXPN))
            log.info(self.LOGLEVEL, self.__str__())
        else:
            raise RuntimeError()
Example #3
0
def daemon():
    #Spawn process per a section header.
    location = os.path.dirname(os.path.realpath(__file__))
    try:
        config = MyConfig(os.path.join(location, 'monitor.config'))
    except (ValueError, KeyError) as msg:
        LOGGER.critical(msg)
        sys.exit(1)
    manager = multiprocessing.Manager()
    health_dict = manager.dict()
    #Can I move this into the below loop? <------------------------###
    for section in config.__dict__.keys():
        if 'grpc' not in section:
            health_dict[section] = False
    health_dict['flushed'] = False
    jobs = []
    #Create lock object to ensure gRPC is only used once
    lock = multiprocessing.Lock()
    for section in config.__dict__.keys():
        if 'grpc' not in section:
            d = multiprocessing.Process(name=section, target=monitor, args=(
                section,
                lock,
                config,
                health_dict
                )
            )
            jobs.append(d)
            d.start()
    try:
        for job in jobs:
            job.join()
    except KeyboardInterrupt:
        print('Keyboard interrupt received.')
        for job in jobs:
            job.terminate()
            job.join()
Example #4
0
#!/usr/bin/python3
import os
import os.path
import sys
from subprocess import Popen, PIPE
from argparse import ArgumentParser
import utils
from myconfig import MyConfig

#Please `make -f Makefile.data prepare` first

config = MyConfig()

#change cwd to the libpinyin data directory
libpinyin_dir = config.getEvalsDir()
libpinyin_sub_dir = os.path.join(libpinyin_dir, 'data')
os.chdir(libpinyin_sub_dir)
#chdir done

datafiles = [config.getFinalModelFileName(), \
             config.getEvalsTextFileName(), \
             'deleted_bigram.db']


def checkData():
    #check data files
    for onefile in datafiles:
        if not os.access(onefile, os.F_OK):
            sys.exit('missing one data file:' + onefile)

Example #5
0
    def __init__(self, args=None):
        super(operateGarage, self).__init__()
        self.ProgramName = "operate Garage Shutters"
        self.Version = "Unknown"
        self.log = None
        self.IsStopping = False
        self.ProgramComplete = False

        if args.ConfigFile == None:
            self.ConfigFile = "/etc/operateGarage.conf"
        else:
            self.ConfigFile = args.ConfigFile

        self.console = SetupLogger("shutters_console",
                                   log_file="",
                                   stream=True)

        ## should be re-enabled before actual production use
        # if os.geteuid() != 0:
        #     self.LogConsole("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'.")
        #     sys.exit(1)

        if not os.path.isfile(self.ConfigFile):
            self.LogConsole("Creating new config file : " + self.ConfigFile)
            defaultConfigFile = os.path.dirname(
                os.path.realpath(__file__)) + '/defaultConfig.conf'
            print(defaultConfigFile)
            if not os.path.isfile(defaultConfigFile):
                self.LogConsole("Failure to create new config file: " +
                                defaultConfigFile)
                sys.exit(1)
            else:
                copyfile(defaultConfigFile, self.ConfigFile)

        # read config file
        self.config = MyConfig(filename=self.ConfigFile, log=self.console)
        result = self.config.LoadConfig()
        if not result:
            self.LogConsole("Failure to load configuration parameters")
            sys.exit(1)

        # log errors in this module to a file
        self.log = SetupLogger("shutters",
                               self.config.LogLocation + "operateGarage.log")
        self.config.log = self.log

        if self.IsLoaded():
            self.LogWarn("operateGarage.py is already loaded.")
            sys.exit(1)

        if not self.startPIGPIO():
            self.LogConsole("Not able to start PIGPIO")
            sys.exit(1)

        self.shutter = Shutter(log=self.log, config=self.config)

        # atexit.register(self.Close)
        # signal.signal(signal.SIGTERM, self.Close)
        # signal.signal(signal.SIGINT, self.Close)

        self.mqtt = MQTT(kwargs={
            'log': self.log,
            'shutter': self.shutter,
            'config': self.config
        })

        self.ProcessCommand(args)
Example #6
0
""" api """
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
####
from password_strength import PasswordPolicy
import pyotp
####
from mymongo import MyMongo
from mylog import MyLog
from myconfig import MyConfig

# pylint: disable=fixme

c = MyConfig()
l = MyLog(c.cfg['virtualenv']['dir'] + '_api')

appname = c.cfg['virtualenv']['dir']

mongohost = c.cfg['dbs']['mongo']['host']
mongodb = c.cfg['dbs']['mongo']['db']
sessionHashSecret = c.cfg['session']['hash_secret']

passpolicylength = c.cfg['password_strength']['length']
passpolicyuppercase = c.cfg['password_strength']['uppercase']
passpolicynumbers = c.cfg['password_strength']['numbers']
passpolicyspecial = c.cfg['password_strength']['special']
passpolicy = PasswordPolicy.from_names(
    length=passpolicylength,  # min length
    uppercase=passpolicyuppercase,  # need min. uppercase letters
    numbers=passpolicynumbers,  # need min. digits
Example #7
0
                    "rvec": rvecs.tolist(),
                    "tvec": tvecs.tolist()
                }).encode("utf-8")
                # #print(data)
                self.sender.send_to(data, ("224.0.0.11", 18888))

            if cv2.waitKey(100) == 27:
                break

        cv2.destroyAllWindows()


if __name__ == "__main__":

    cam = 0
    cf = MyConfig("./charuco.ini")
    conf = cf.conf
    apply_all_cam_settings(conf["HD5000"], cam)

    ct = CharucoTest(cam, cf)

    # #ct.create_markers_pdf()
    # #ct.create_chessboard_png()
    # #ct.create_images_calibration()
    # #ct.show_some_images()
    # #ct.read_chessboards()
    # #ct.calibrate_camera()
    # #ct.calibration_test_init()
    # #ct.calibration_test()
    # #ct.translation_rotation_test()
    ct.detect_one_real_marker()
Example #8
0
    addr = addrs[0]
    return addr['addr']

def sendEmail(conf, addr):
    server = smtplib.SMTP(conf['SMTP_SERVER'], conf['SMTP_PORT'])
    server.ehlo()
    server.starttls()
    server.login(conf['USERNAME'], conf['PASSD'])

    BODY = '\r\n'.join(['To: %s' % conf['TO'],
                       'From: %s' % conf['FROM'],
                       'Subject: %s' % conf['SUBJECT'],
                       '',
                       'The address of your Raspberry Pi on eth0 is %s' % addr])

    print(BODY)
    try:
        server.sendmail(conf['USERNAME'], conf['TO'], BODY)
        print('Email Sent')
    except:
        print('Error sending email')

    server.quit()

if __name__ == "__main__":
    sleep(10)
    conf = MyConfig()
    addr = getIP()
    print(addr)
    sendEmail(conf, addr)
Example #9
0
                    data = json.dumps({
                        "rvec": rvec.tolist(),
                        "tvec": tvec.tolist()
                    }).encode("utf-8")
                    self.sender.send_to(data, ("224.0.0.11", 18888))

            if cv2.waitKey(100) == 27:
                break

        cv2.destroyAllWindows()


if __name__ == "__main__":

    cam = 0
    cf = MyConfig("./aruco.ini")
    conf = cf.conf
    apply_all_cam_settings(conf["HD5000"], cam)

    at = ArucoTest(cam, cf)
    # #at.get_data_calibration()
    # #at.calibrate()
    at.validating_real_time_results()
"""
Rodrigues
[[ 2.2335851 ]
 [-2.0081005 ]
 [ 0.34698185]]

(array([[ 0.09461465, -0.99137014,  0.09073787],
       [-0.96433645, -0.11390218, -0.23891737],
Example #10
0
import os, sys
from time import sleep
import threading

from twisted.internet.endpoints import TCP4ServerEndpoint
from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor

from myconfig import MyConfig
from kinect import Display

# Variable globale
scr = os.path.dirname(os.path.abspath(__file__))

# L'object configuration
conf_obj = MyConfig(scr + "/rezobox_server.ini")
CONF = conf_obj.conf
print("Configuration du serveur: {}\n".format(CONF))

TCP_PORT = CONF["server"]["port"]
TEMPO = float(CONF["server"]["tempo"])
TO_BLEND = None


class MyTcpServer(Protocol):
    def __init__(self, factory):
        self.factory = factory
        self.loop = 1

    def connectionMade(self):
        self.addr = self.transport.client
Example #11
0
from myconfig import MyConfig

config = MyConfig(["settings.toml", ".secrets.toml"])

print(config.some_text)
print(config.some_secrets_text)
print(config.some_text_env)