Beispiel #1
0
    def __init__(self):
        iv = interrupt_vector.InterruptVector()
        btns = buttons.Buttons(iv, conf.config().get('buttons', {}))
        weather_devices = weather_stations.WeatherStations(conf.config().get(
            'weather_stations', []))

        self.target_loop_time = conf.config().get("main_loop",
                                                  {}).get("interval", 32)
        self.minimum_loop_time = conf.config().get("main_loop",
                                                   {}).get("minimum", 1)

        self.thinkers = [
            iv,  # buttons, switches, et al.
            btns,
            weather_devices
        ]

        routes = [('GET', '/weather_stations', 0, weather_devices.list),
                  ('GET', '/weather_stations/(.+)', 1, weather_devices.show)]

        self.poller = select.poll()
        if not hasattr(self.poller, 'ipoll'):
            import uselect
            self.poller = uselect.poll()

        self.server = htserver.HttpServer(self.poller, routes,
                                          conf.config().get('http_server', {}))
Beispiel #2
0
def start_postgres():
    from conf import config

    pg = config()["pg"]
    db_string = f"postgres://{pg['user']}:{pg['password']}@{pg['host']}:{pg['port']}/{pg['database']}"
    db = create_engine(db_string)

    result_set = db.execute("SELECT * from exchanges")
    for r in result_set:
        print(r)
def send_exception_message(ex):
    capture = uio.StringIO()
    sys.print_exception(ex, capture)
    capture.seek(0)
    ex_message = capture.read()

    address = conf.config()["panic_handler"]["address"]
    port = conf.config()["panic_handler"]["port"]
    path = conf.config()["panic_handler"]["path"]

    addr_info = usocket.getaddrinfo(address, port)

    print("Sending Panic Info to:", addr_info)
    s = usocket.socket()
    s.connect(addr_info[0][-1])
    s = s.makefile("rwb", 0)
    s.write(
        bytes(
            "POST {} HTTP/1.0\r\nContent-Length: {}\r\n\r\n{}".format(
                path, len(ex_message), ex_message), "utf-8"))
    s.read()
    s.close()
Beispiel #4
0
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        locale = QSettings().value("locale/userLocale")[0:2]
        localePath = os.path.join(self.plugin_dir, 'i18n', 'configurazione_{}.qm'.format(locale))

        if os.path.exists(localePath):
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        # Create the dialog (after translation) and keep reference
        (dirPlugins,plugDir) = os.path.split(self.plugin_dir)
        self.cfg = config(dirPlugins)
        self.updateGlobalVariable()
        self.dlg = configurazioneDialog()
        self.dlg.terstBtn.clicked.connect(self.test_connetti_db)
        self.dlg.fileButton.clicked.connect(self.select_DTM_file)
Beispiel #5
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
# see main.py for copyright, contacts and version information
#
# Hinweis: uebergebene Strings muessen im UTF-8-Encoding sein

import xmlrpclib
import random

import conf

global config
config=conf.config()

########################################################### 
# Homematic 
########################################################### 
class Homematic:
    
    licht_wz = False
    licht_az = False
    licht_sz = False
    
    def get_value(self, interface, addr, channel, value_key):  
        '''
        
        '''
        if interface == 'wired':
            port = 2000
        if interface == 'wireless':
Beispiel #6
0
from phue import Bridge
import pyowm

## snom libs:
import conf
import commands
from snom import SnomXML
from http import ThreadingServer
import rapi_system
import RPi.GPIO as GPIO

# pacman -S python2-pip
# pip2 install simplejson

global config
config=conf.config()

# global picture 

icons_url = config['icons_url'] 

# import json
import urllib2

snomXML = SnomXML()

# Hue-Helligkeit = 0-254:
command = commands.Commands(config['brightness'])

system = rapi_system.RaPi_System()
Beispiel #7
0
from threading import Thread
import vlc

import send_sms
import g_drive
import conf
import camera_conf
import notify

#GoogleDrive Authentication
g_drive.authentication()
gauth = g_drive.get_gauth()
drive = g_drive.get_drive()

#Initialise conf.py file
conf = conf.config()

# filter warnings
warnings.filterwarnings("ignore")

#Initialise camera info
camera = camera_conf.init_camera()
lastUploaded = camera_conf.get_lu()
avg = camera_conf.get_avg()
motionCounter = camera_conf.get_mc()

# initialise sound file
player = vlc.MediaPlayer("file:///home/pi/securiPi/soundFiles/Siren.mp3")


def threaded_music():
Beispiel #8
0
from . import home
import os
import subprocess
from wtforms import Form, StringField, SelectField
import sqlite3
from sqlite3 import Error
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import DataRequired
import sys

sys.path.append("..")
from merrors import merrors
import conf

configs = conf.config()
configs.read()
name = configs.get("name")
print(name)
Merrors = merrors()
Merrors.error("Test")


#Form stuff
class NewSurveyFormQuestions(FlaskForm):
    question = StringField('Question', validators=[DataRequired()])
    #answer = StringField('Answers', validators=[DataRequired()])
    category = SelectField(
        'Category',
        choices=[('s_text', 'Short text'), ('radio', 'Radio choices'),
                 ('m_text', 'Multiple choice'),
Beispiel #9
0
    def __init__(self):
        builder = gtk.Builder()
        builder.add_from_file("tercihler.glade")
        self.window = builder.get_object("pencere")
        self.window.connect("delete-event", self.ayarver)

        vbox = builder.get_object("vbox2")
        iconview_ = iconview.iconview()
        vbox.pack_start(iconview_, True, True, 3)

        hbox = gtk.HBox()
        kal = self.rlb(gtk.STOCK_REMOVE, "Delete ", iconview_.remove, "Delete")
        ekle = self.rlb(gtk.STOCK_ADD, "Add ", iconview_.ekle, "Add")
        far = self.rlb(gtk.STOCK_SAVE_AS, "Save As", iconview_.far, "Save As")
        save_ = self.rlb(gtk.STOCK_SAVE, "Save", iconview_.save_, "Save")
        ac = self.rlb(gtk.STOCK_OPEN, "Open", iconview_.open, "Open")

        hbox.pack_start(ac, False, True, 3)
        hbox.pack_start(far, False, True, 3)
        hbox.pack_start(save_, False, True, 3)

        hbox.pack_start(iconview_.label, True, True, 3)
        hbox.pack_start(kal, False, False, 3)
        hbox.pack_start(ekle, False, False, 3)
        vbox.pack_start(hbox, False, False, 3)

        self.sanval = builder.get_object("hscale1")
        self.dakval = builder.get_object("hscale2")
        self.satval = builder.get_object("hscale3")

        self.saniye = builder.get_object("checkbutton2")
        self.saniye.connect("toggled", self.che, "saniye", self.sanval)
        self.sanval.set_sensitive(False)
        self.dakika = builder.get_object("checkbutton3")
        self.dakika.connect("toggled", self.che, "dakika", self.dakval)
        self.dakval.set_sensitive(False)
        self.saat = builder.get_object("checkbutton4")
        self.saat.connect("toggled", self.che, "saat", self.satval)
        self.satval.set_sensitive(False)

        self.basla = builder.get_object("checkbutton1")
        self.basla.connect("toggled", self.che, "basla", False)
        self.ras = builder.get_object("checkbutton5")
        self.ras.connect("toggled", self.che, "rastgele", False)

        hbox = builder.get_object("hbox1")
        vbox = builder.get_object("vbox1")
        buton = gtk.Button("Yardım")
        buton.connect("clicked", self.pes)
        hbbox = gtk.HButtonBox()
        hbbox.add(buton)
        buton = gtk.Button(" Kapat")
        buton.connect("clicked", self.ayarver, False)

        hbbox.add(buton)
        vbox.pack_start(hbbox, False, False, 0)
        import conf
        self.ayar = conf.config("tercihler.cfg")
        self.ayaral()

        self.window.show_all()
Beispiel #10
0
    def __init__(self, NirGis):
        self.iface = NirGis.iface
        self.NG = NirGis

        self.nomeDelModulo = u"Configurazione"
        self.versione = "4.0"
        self.sperimentale = False
        self.lstMenu = [["Configurazione NirGis", self.run, ""],
                        ["Cambia legende/stili", self.ridefinisciStile, ""],
                        ["Aiuto", self.apri_wiki, ""],
                        ["NirGis", self.mostraversione, ""]]

        self.url = "http://wiki.arpa.veneto.it/index.php/Manuale_utilizzo_NirGis_17.05"
        self.dlg = configurazioneDialog()

        dizOpz = {}
        lProv = [
            "", "Belluno", "Padova", "Rovigo", "Treviso", "Venezia", "Vicenza",
            "Verona"
        ]
        self.codProv = ["0", "25", "28", "29", "26", "27", "24", "23"]
        self.dizProv = dict(zip(range(8), zip(self.codProv, lProv)))
        self.dlg.CB_PROVINCIA.insertItems(0, lProv)
        self.dlg.btnCambiaPassword.clicked.connect(self.cambiaPassword)
        self.dbModified = False  # per controllare se la connessione deve essere reimpostata
        self.isMultiQmlRun = False  # per ridefinizione stile qml
        # Definizione del dizionario delle opzioni

        #########################################################
        # Per inserire una nuova opzione aggiungere una casella di testo QLineEdit o
        # una CheckBox nella Finestra di dialogo self.dlg e poi aggiungere una
        # riga nel dizionario dizOpz qui sotto.
        # Il dizionario deve avere come chiave il nome dell'opzione e
        # il contenuto è una lista di 4 valori:
        #   0: valore di default della opzione
        #   1: Stinga di informazione di default della opzione
        #   2: Tipo di opzione "TEXT" se si usa una QLineEdit, "BOOL" se è una QCheckBox e COMBO se è un QComboBox
        #   3: l'oggetto di riferimento nella finestra di dialogo
        #########################################################

        dizOpz["PROVINCIA_DEFAULT"] = ["", "", "COMBO", self.dlg.CB_PROVINCIA]
        dizOpz["DB_ADDR"] = ["", "", "TEXT", self.dlg.DB_ADDR]
        dizOpz["DB_NAME"] = ["", "", "TEXT", self.dlg.DB_NAME]
        dizOpz["DB_USERNAME"] = ["", "", "TEXT", self.dlg.DB_USERNAME]
        dizOpz["DB_PASSWORD"] = ["", "", "TEXT", self.dlg.DB_PASSWORD]
        dizOpz["DB_SCHEMA"] = ["", "", "TEXT", self.dlg.DB_SCHEMA]
        dizOpz["SAVE_PRG_BEFORE_DB_CONN"] = [
            True, "", "BOOL", self.dlg.SAVE_PRG_BEFORE_DB_CONN
        ]
        dizOpz["CS_INDIRIZZO"] = [False, "", "BOOL", self.dlg.CS_INDIRIZZO]
        dizOpz["CS_RESPIMP"] = [False, "", "BOOL", self.dlg.CS_RESPIMP]
        dizOpz["CS_NOTE1"] = [False, "", "BOOL", self.dlg.CS_NOTE1]
        dizOpz["CS_RESP"] = [False, "", "BOOL", self.dlg.CS_RESP]
        dizOpz["CS_ID_PADRE"] = [False, "", "BOOL", self.dlg.CS_ID_PADRE]
        dizOpz["CS_NOTE2"] = [False, "", "BOOL", self.dlg.CS_NOTE2]
        dizOpz["CS_CREAZIONE"] = [False, "", "BOOL", self.dlg.CS_CREAZIONE]
        dizOpz["CS_DATAMODIFY"] = [False, "", "BOOL", self.dlg.CS_DATAMODIFY]
        dizOpz["CS_PARERE"] = [False, "", "BOOL", self.dlg.CS_PARERE]
        dizOpz["CS_COMUNICAZ"] = [False, "", "BOOL", self.dlg.CS_COMUNICAZ]
        dizOpz["CS_DISMISSION"] = [False, "", "BOOL", self.dlg.CS_DISMISSION]
        dizOpz["CS_COMUNE"] = [False, "", "BOOL", self.dlg.CS_COMUNE]
        dizOpz["CS_PONTE"] = [False, "", "BOOL", self.dlg.CS_PONTE]
        dizOpz["CS_POST"] = [False, "", "BOOL", self.dlg.CS_POST]
        dizOpz["CS_DISMESSI"] = [False, "", "BOOL", self.dlg.CS_DISMESSI]
        dizOpz["PASSO_MAX_CAMPO_ED"] = [
            "0.5", "", "TEXT", self.dlg.lePassoMaxEd
        ]
        dizOpz["STILE_EDIFICI_MAX_CAMPO"] = [
            True, "", "BOOL", self.dlg.cbLegMaxCampo
        ]
        dizOpz["STILE_EDIFICI_SEZ_ORIZZ"] = [
            True, "", "BOOL", self.dlg.cbLegSezEd
        ]
        dizOpz["UP_GRONDA"] = ["0.0", "", "TEXT", self.dlg.leUpGronda]
        dizOpz["ALFA24"] = [True, "", "BOOL", self.dlg.ALFA24]
        dizOpz["SAVE_ALL_XML"] = [True, "", "BOOL", self.dlg.SAVE_ALL_XML]
        dizOpz["FILE_DTM"] = ["", "", "TEXT", self.dlg.FILE_DTM]
        dizOpz["CARTELLA_FILE_STILE"] = [
            "", "", "TEXT", self.dlg.CARTELLA_FILE_STILE
        ]
        dizOpz["MAX_IMPIANTI_ANT"] = [
            "100",
            "Massimo numero di siti dove verranno scaricate anche le antenne",
            "TEXT", self.dlg.leMaxImpiantiAnt
        ]
        dizOpz["CAMPOCRITICO"] = [
            "6.0",
            "Valore di campo utilizzato per calcolare l'altezza critica degli edifici",
            "TEXT", self.dlg.leCampoCritico
        ]
        dizOpz["UPGRONDACRITICO"] = [
            "2.0",
            "Incremento sulla gronda degli edifici per calcolare l'altezza critica",
            "TEXT", self.dlg.leUpGrondaCritico
        ]
        # Fine definizione definizioni delle opzioni
        self.cfg = config(dizOpz)
        # Declare instance attributes

        self.dlg.terstBtn.clicked.connect(self.test_connetti_db)
        self.dlg.fileButton.clicked.connect(self.select_DTM_file)
        self.dlg.stileButton.clicked.connect(self.select_Cartella_Stile)
        self.LastPassoEd = self.dlg.lePassoMaxEd.text()
        self.LastUpGronda = self.dlg.leUpGronda.text()
        self.LastMaxImpiantiAnt = self.dlg.leMaxImpiantiAnt.text()
        self.LastCampoCritico = self.dlg.leCampoCritico.text()
        self.LastUpGrondaCritico = self.dlg.leUpGrondaCritico.text()
        self.dlg.leMaxImpiantiAnt.textChanged.connect(self.aggiornaMaxImpianti)
        self.dlg.lePassoMaxEd.textChanged.connect(self.aggiornaPassoEd)
        self.dlg.leUpGronda.textChanged.connect(self.aggiornaUpGronda)
        self.dlg.leCampoCritico.textChanged.connect(self.aggiornaCampoCritico)
        self.dlg.leUpGrondaCritico.textChanged.connect(
            self.aggiornaUpGrondaCritico)
        self.cambioLayEdificiCalc = False
        self.dlg.cb_edifici.currentIndexChanged.connect(
            self.cambioLayEdifici
        )  # cambia la selezione del layer edifici dal menu a tendina
        self.dlg.cbStatEdifici.stateChanged.connect(
            self.aggiornaStatEdifici
        )  # cambia il check sulle statistiche degli edifici
        self.dlg.DB_ADDR.textChanged.connect(self.dbModificato)
        self.dlg.DB_SCHEMA.textChanged.connect(self.dbModificato)
        self.dlg.DB_NAME.textChanged.connect(self.dbModificato)
        self.dlg.DB_USERNAME.textChanged.connect(self.dbModificato)
        self.dlg.DB_PASSWORD.textChanged.connect(self.dbModificato)
Beispiel #11
0
# | '_ \ / __| '_ ` _ \| | | / __| |/ __| #
# | | | | (__| | | | | | |_| \__ \ | (__  #
# |_| |_|\___|_| |_| |_|\__,_|___/_|\___| #
#                                         #
###########################################

import curses
import glob
import os
import os.path
import pathlib
import sys
import time
from modules import MPVPlayer
from conf import config
Config = config()
Player = MPVPlayer(Config.MPV_Path, None)


def formatter(
    width, state, path
):  # this system won't work because the formatter is just formatting the text - has no concept of the screen
    item = str(path)
    if state == 1:  # album
        item = item.split("/")[1]
        if len(item) >= width:
            item = item[:width - 4]
            item = (item + "...")
    elif state == 2:  # song
        item = item.split("/")[2]
        item = item.removesuffix(".mp3")
Beispiel #12
0
import packer

from pathlib import Path
import sys

sys.path.append("..")

from merrors import merrors
import conf
from flask import app

Merrors = merrors()
Merrors.error("Test")

# Configs
config = conf.config()
home_path = str(Path.home())
config.read(home_path + "/.keyos/config.json")

##########################################################################
# Themes, for information on creating a theme please refer to the guides.
#
#
#
#
#
##########################################################################

glob_themes = []
current_theme = None
Beispiel #13
0
import configparser
from ssh import ssh
from db import database
from conf import config
from runner import runner

config_file = configparser.ConfigParser()
config_file.read('example.conf')
db = database(config_file)

config = config(db, config_file)
config.loadConfig()

rn = runner(db)
rn.run()
import conf
import helpers

# Configuration parameters pulled from conf.py
bbc_radio6_url = conf.config('bbc_show_url')
start_date = conf.config('start_date')
end_date = conf.config('end_date')


def main():
    """
    Workflow function to print a list of all playlists within a date range.

    In development, need to change output to otuput to MongoDB.

    """

    print("Retreiving BBC playlists for dates between {} and {}".format(
        start_date.strftime("%Y-%m-%d"), end_date.strftime("%Y-%m-%d")))

    # Get daily schedule URLs within date range
    radio6_schedule_list = helpers.bbc_daily_schedule_urls(
        bbc_radio6_url, helpers.get_date_list(start_date, end_date))

    # Get all show URLS
    all_program_urls = []
    for url in radio6_schedule_list:
        all_program_urls += helpers.bbc_program_urls(url)

    # Get all track playlists from program URLs
    track_lists = []
Beispiel #15
0
def configure_cpu():
    cpu_config = conf.config().get('cpu', {})
    if 'freq' in cpu_config:
        freq = int(cpu_config['freq'])
        print("Setting machine to freq: {}".format(freq))
        machine.freq(freq)