示例#1
0
 def okButton_clicked(self):
   SwineProgramDialog.okButton_clicked(self)
   self.hide()
   self.parent.runShortcut(self.shortcut)
   if config.getValue("auto_import_shortcuts"):
     SwineShortcutImportDialog(self.shortcut.slot, self, onlyNew=True).exec_()
     self.parent.reloadShortcuts()
示例#2
0
 def load(self):
   self.winePath.clear()
   self.winePath.addItem("System [%s]" % swinelib.getWineVersion(None), None)
   for path in config.getValue("wine_paths"):
     version = swinelib.getWineVersion(path)
     self.winePath.addItem("%s [%s]" % (path, version), path)
   self.winePath.setCurrentIndex(max(0, self.winePath.findData(self.slot.getWinePath())))
示例#3
0
def msg_update_config(topic, payload):
    logging.info("Received config: %s" % (payload))
    global config
    global hostsConfig
    if mqtt.MQTT.topic_matches_sub(
            hostmqtt, myHostname + "/" + DEVICENAME + "/update_config", topic):
        logging.info("Setting config")
        # TODO: OMG ew!
        config.cfg = mqtt.get(payload, 'config', {})
        hostsConfig = config.getValue("hosts", {})
示例#4
0
def isPluginEnabled(name):
    enabled_plugins = set(config.getValue("general",
                                          "enabledPlugins",
                                          [None]))
    print(("EP:", enabled_plugins))
    if enabled_plugins == set([None]):
        print("FLAG")
        #Never configured... enable everything! (will change later ;-)
        enabled_plugins = set()
        for c in manager.getCategories():
            for p in manager.getPluginsOfCategory(c):
                enabled_plugins.add(p.name)
    return name in enabled_plugins
示例#5
0
 def load(self):
   self._addWinePath("System", swinelib.getWineVersion(None))
   for path, version in config.getValue("wine_paths").iteritems():
     self._addWinePath(path, version)
   self._winePathsChanged()
   self.defaultWinePath.setCurrentIndex(max(0, self.defaultWinePath.findData(config.getValue("default_wine_path"))))
   self.allowMenuEntryCreation.setChecked(config.getValue("allow_menu_entry_creation"))
   self.autoImportShortcuts.setChecked(config.getValue("auto_import_shortcuts"))
   self.debugLine.setText(config.getValue("debug_line"))
   self.architecture.setCurrentIndex(max(0, self.architecture.findText(config.getValue("architecture"))))
示例#6
0
def startServices():
    if myHostname not in hostsConfig:
        logging.log("%s not in hosts config" % (myHostname))
        return
    hostConfig = hostsConfig[myHostname]
    deploymentType = hostConfig["type"]
    deployments = config.getValue("deployments", {})
    for devicename in deployments[deploymentType]:
        t = deployments[deploymentType][devicename]["type"]
        logging.info("Starting " + t)

        hostmqtt.status({"starting": t})

        cmd = './' + t + '/main.py'
        process = subprocess.Popen(
            [cmd, myHostname, deploymentType, devicename],
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
        )
示例#7
0
 def winetricks(self, tool):
   self.slot.runWinetricks(tool)
   if config.getValue("auto_import_shortcuts"):
     SwineShortcutImportDialog(self.slot, self.listWidget(), onlyNew=True).exec_()
     self.refreshShortcutList()
示例#8
0
 def runVerb(self, path):
   self.slot.runVerb(path)
   if config.getValue("auto_import_shortcuts"):
     SwineShortcutImportDialog(self.slot, self.listWidget(), onlyNew=True).exec_()
     self.refreshShortcutList()
示例#9
0
def ensureRulesFiles(config):
    for ruletype in ["blacklist", "whitelist", "tcp", "udp"]:
        filepath = config.getValue("RULES", "filepath")
        filename = config.getValue("RULES", ruletype)
        utility.createFolderIfNotExists(filepath)
        utility.createFileIfNotExists(filepath + "/" + filename)
示例#10
0
import time
import sys
import socket
import traceback
from time import sleep

allMuted = False
repeats = {}

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import mqtt
import config

myHostname = config.getValue("hostname", socket.gethostname())

master_mqtt_host = config.getValue("mqttmaster", "mqtt.thegame.folly.site")
mastermqtt = mqtt.MQTT(master_mqtt_host, myHostname, "relay_to", "everyone",
                       "S4C7Tzjc2gD92y9", 1883)
#mastermqtt.loop_start()   # use the background thread

# end load config

mastermqtt.status({"status": "listening"})
mastermqtt.publish("hello", {"once": "we"})

try:
    #while True:
    #    sleep(1)
    mastermqtt.loop_forever()
示例#11
0
 def loadFeeds(self):
     self.feeds = config.getValue("RSSPlugin", "feeds", [])
     self.feedList.clear()
     for title,url in self.feeds:
         i = QtGui.QListWidgetItem(title, self.feedList)
         self.feedList.addItem(i)
示例#12
0
allMuted = False
repeats = {}

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import mqtt
import config

sleep(5)

myHostname = config.getHostname()
deploymenttype = config.getDeploymentType()
DEVICENAME = config.getDevicename()

mqttHost = config.getValue("mqtthostname", "localhost")
if mqttHost == "mqtt.thegame.folly.site":
    hostmqtt = mqtt.MQTT(mqttHost, myHostname, DEVICENAME, "everyone",
                         "S4C7Tzjc2gD92y9", 8883)
else:
    hostmqtt = mqtt.MQTT(mqttHost, myHostname, DEVICENAME)
hostmqtt.loop_start()  # use the background thread

master_mqtt_host = config.getValue("mqttmaster", "mqtt.thegame.folly.site")
mastermqtt = mqtt.MQTT(master_mqtt_host, myHostname, "relay_to", "everyone",
                       "S4C7Tzjc2gD92y9", 8883)

#mastermqtt.loop_start()   # use the background thread

# end load config
示例#13
0
def ensure_rules_files(config):
    for ruletype in ["blacklist", "whitelist", "tcp", "udp"]:
        filepath = config.getValue("RULES", "filepath")
        filename = config.getValue("RULES", ruletype)
        utility.create_folder_if_not_exists(filepath)
        utility.create_file_if_not_exists(filepath + "/" + filename)
示例#14
0
import time
import argparse
import logging
import os

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import config
import mqtt
import subprocess

DEVICENAME = "deployment"
myHostname = config.getHostname(False)

mqttHost = config.getValue("mqtthostname", "localhost")
for i in range(0, 25):
    time.sleep(1)
    response = os.system("ping -c 1 " + mqttHost)
    if response == 0:
        break
    logging.info("Waiting for %s: attempt %s" % (mqttHost, i))

mqttMasterHost = config.getValue("mqttmaster", "")
if mqttMasterHost != "":
    for i in range(0, 25):
        time.sleep(1)
        response = os.system("ping -c 1 " + mqttMasterHost)
        if response == 0:
            break
        logging.info("Waiting for %s: attempt %s" % (mqttMasterHost, i))
示例#15
0
def get_config():
    """Retrieves the current network configuration"""
    return config.getValue('network', 'proxy', None)
示例#16
0
文件: main.py 项目: webmedic/booker
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        uifile = ui.path('main.ui')
        uic.loadUi(uifile, self)
        self.ui = self
        self.viewers = []
        self.currentBook = None

        # Set default stylesheet for all web views in the app
        wksettings = QtWebKit.QWebSettings.globalSettings()
        # FIXME: this doesn't work
        wksettings.setMaximumPagesInCache(0)
        ssurl = QtCore.QUrl().fromLocalFile(
                        os.path.join(os.path.dirname(__file__), 'master.css'))
        wksettings.setUserStyleSheetUrl(ssurl)

        # View types toggles
        self.viewGroup = QtGui.QButtonGroup(self)
        self.viewGroup.setExclusive(True)
        self.viewGroup.addButton(self.gridMode)
        self.viewGroup.addButton(self.listMode)
        self.viewGroup.buttonClicked.connect(self.viewModeChanged)
        self.gridMode.setChecked(True)

        # Search Bar
        self.searchBar = QtGui.QToolBar()
        self.addToolBar(QtCore.Qt.BottomToolBarArea, self.searchBar)
        self.searchWidget = SearchWidget()
        self.searchBar.addWidget(self.searchWidget)
        self.searchBar.hide()
        self.searchWidget.closeBar.clicked.connect(self.searchBar.hide)

        self._layout = QtGui.QVBoxLayout()
        self.details.setLayout(self._layout)
        self.book_editor = BookEditor(None)
        self.book_editor.cancel.clicked.connect(self.viewModeChanged)
        self.book_editor.save.clicked.connect(self.viewModeChanged)
        self.book_editor.updateBook.connect(self.updateBook)
        self._layout.addWidget(self.book_editor)

        #About this Book
        self._layout2 = QtGui.QVBoxLayout()
        self.about.setLayout(self._layout2)
        self.about_book = AboutBook(None)
        self.about_book.closeButton.clicked.connect(self.viewModeChanged)
        self.about_book.editButton.clicked.connect(
                                            self.on_actionEdit_Book_triggered)
        self.about_book.about_web_view.linkClicked.connect(
                                            self.about_book_openLink)
        self._layout2.addWidget(self.about_book)

        print("Finished initializing main window")

        self.loadPlugins()
        geom = config.getValue("general", "geometry", None)
        if geom is not None:
            self.restoreGeometry(geom)

        downloader.downloader = downloader.Downloads()
        downloader.downloader.setStatusMessage.connect(self.setStatusMessage)
        self.statusBar.addPermanentWidget(downloader.downloader)
        self.progBar = QtGui.QProgressBar()
        self.progBar.setMaximumWidth(100)
        self.statusBar.addPermanentWidget(self.progBar)
        self.progBar.setVisible(False)
示例#17
0
文件: main.py 项目: webmedic/booker
    def loadPlugins(self):
        # FIXME: separate by category so you can load just one

        # Plugins
        manager.locatePlugins()
        manager.loadPlugins()

        enabled_plugins = set(config.getValue("general",
                                              "enabledPlugins",
                                              [None]))
        if enabled_plugins == set([None]):
            enabled_plugins = set()
            #Never configured... enable everything! (will change later ;-)
            for c in manager.getCategories():
                for p in manager.getPluginsOfCategory(c):
                    enabled_plugins.add(p.name)

        self.treeWidget.clear()

        for plugin in manager.getPluginsOfCategory("ShelfView"):
            # Ways to fill the shelves
            if plugin.name not in enabled_plugins:
                continue
            item = plugin.plugin_object.treeItem()
            item.handler = plugin.plugin_object
            item.title = plugin.plugin_object.title
            plugin.plugin_object.setWidget(self)
            self.treeWidget.addTopLevelItem(item)
            if item.handler.itemText == "Titles":
                self.on_treeWidget_itemClicked(item)
                self.treeWidget.setCurrentItem(item)

        for plugin in manager.getPluginsOfCategory("BookStore"):
            # Ways to acquire books
            if plugin.name not in enabled_plugins:
                continue

            # Hook progress report signals
            plugin.plugin_object.loadStarted.connect(self.loadStarted)
            plugin.plugin_object.loadFinished.connect(self.loadFinished)
            plugin.plugin_object.loadProgress.connect(self.loadProgress)
            plugin.plugin_object.setStatusMessage.connect(
                                                      self.setStatusMessage)

            # Add to the Store list
            item = plugin.plugin_object.treeItem()
            item.handler = plugin.plugin_object
            item.title = plugin.plugin_object.title
            plugin.plugin_object.setWidget(self)
            self.treeWidget.addTopLevelItem(item)

        self.menuDevices.clear()

        for plugin in manager.getPluginsOfCategory("Device"):
            if plugin.name not in enabled_plugins:
                continue
            dev_menu = QtGui.QMenu(plugin.plugin_object.name, self)
            print(("Adding menu:", plugin.plugin_object.name))
            for a in plugin.plugin_object.deviceActions():
                print(a)
                dev_menu.addAction(a)
            dev_menu.addSeparator()
            dev_menu.addAction(plugin.plugin_object.actionNew())
            self.menuDevices.addMenu(dev_menu)
示例#18
0
def getQueryAdress():
    ip = str(config.getValue("serverIP"))
    port = int(config.getValue("serverPort")) + 1  # query port is +1
    return (ip, port)
示例#19
0
allMuted = False
repeats = {}

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import mqtt
import config
import datetime

myHostname = config.getHostname()
deploymenttype = config.getDeploymentType()
DEVICENAME = config.getDevicename()

mqttHost = config.getValue("mqtthostname", "localhost")
hostmqtt = mqtt.MQTT(mqttHost, myHostname, DEVICENAME)
hostmqtt.loop_start()

# see https://github.com/gotthardp/python-mercuryapi
import mercury

# end load config

########################################
lastRead = {}


def rfidTagDataCallback(rfid):
    try:
        #if rfid.epc.hex() in lastRead:
示例#20
0
import bot
import config
import discord

client = discord.Client()
bot.registerCommands(client)

try:
    client.run(config.getValue("token"))
except discord.errors.LoginFailure:
    print("An improper token has been supplied in config.json")
    print("Exiting")
    raise SystemExit
示例#21
0
文件: swinelib.py 项目: dswd/Swine
 def __getitem__(self, key):
   return self.settings.get(key, config.getValue(key))
示例#22
0
 def updateFeeds(self):
     self.feeds = config.getValue("RSSPlugin", "feeds", [])
     for title, url in self.feeds:
         updateFeedBook(title, url)
示例#23
0
    except:
        logging.info("DMX failed on USB1")
        try:
            mydmx = pysimpledmx.DMXConnection("/dev/ttyUSB2")
        except:
            logging.info("DMX failed on USB2")
            try:
                mydmx = pysimpledmx.DMXConnection("/dev/ttyUSB3")
            except:
                logging.info("DMX failed on USB3")
                try:
                    mydmx = pysimpledmx.DMXConnection("/dev/ttyUSB4")
                except:
                    logging.info("DMX failed on USB4")

mqttHost = config.getValue("mqtthostname", "localmqttforsure")
myHostname = config.getValue("hostname", socket.gethostname())
hostmqtt = mqtt.MQTT(mqttHost, myHostname, "relay_from")
#hostmqtt.loop_start()   # use the background thread

#master_mqtt_host = config.getValue("mqttmaster", "mqtt.thegame.folly.site")
#mastermqtt = mqtt.MQTT(master_mqtt_host, myHostname, "relay_to", "everyone", "S4C7Tzjc2gD92y9", 1883)


def stopthathorribleflashing():
    logging.info("stoppit")
    for i in range(2, 500):
        mydmx.setChannel(i, 0)
    mydmx.render()

示例#24
0
import sys

sys.path.append("../utils")
import config

print(config.getValue(section="log", key="log1"))
示例#25
0
# for midi generation
from pyo import *
import random

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import config
import mqtt

myHostname = config.getHostname()
deploymenttype = config.getDeploymentType()
DEVICENAME = config.getDevicename()

mqttHost = config.getValue("mqtthostname", "localhost")
hostmqtt = mqtt.MQTT(mqttHost, myHostname, DEVICENAME)
hostmqtt.loop_start()  # use the background thread

sounddir = config.getValue("sounddir", "../../sounds/")
testsound = config.getValue("testsound", "test.wav")

isMuted = False


def main():
    s = Server(duplex=0)
    s.setOutputDevice(pa_get_default_output())
    s.boot()
    s.start()
    time.sleep(1)
示例#26
0
文件: main.py 项目: FollyEngine/RPi
import logging

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import config
import mqtt
sys.path.append('./crickit/')
import myneopixels


myHostname = config.getHostname()
deploymenttype=config.getDeploymentType()
DEVICENAME=config.getDevicename()

mqttHost = config.getValue("mqtthostname", "localhost")
hostmqtt = mqtt.MQTT(mqttHost, myHostname, DEVICENAME)
hostmqtt.loop_start()   # use the background thread

hostsConfig = config.getValue("hosts", {})
deployments = config.getValue("deployments", {})

logging.info(deployments)

settings = deployments[deploymenttype][DEVICENAME]

logging.info(settings)

# TODO: should get default from DEVICE type, and then over-ride from host settings
#num_pixels = 64  # Number of pixels driven from Crickit NeoPixel terminal
#pixels = NeoPixel(crickit.seesaw, 20, num_pixels)
示例#27
0
文件: main.py 项目: FollyEngine/RPi
import paho.mqtt.publish as publish
import time
import sys
import socket
import traceback

allMuted = False
repeats = {}

# the config and mqtt modules are in a bad place atm :/
import sys
sys.path.append('./mqtt/')
import mqtt
import config

mqttHost = config.getValue("mqtthostname", "mqtt")
myHostname = config.getValue("hostname", socket.gethostname())
hostmqtt = mqtt.MQTT(mqttHost, myHostname, "controller")

currentState = "NEWNEWNEW"  #config.getValue("start_state", "PodiumX")

# end load config


############
def muteAll():
    hostmqtt.publishL("all", "audio", "mute", {})


############
def unMuteAll():
示例#28
0
    def expire(self, expunge=False):
        '''Delete all posts that are too old'''
        # meaning of archiveType:
        # 0 = use default, 1 = keepall, 2 = use limitCount
        # 3 = use limitDays, 4 = no archiving
        now=datetime.datetime.now()
        if self.archiveType==0: # Default archive config
            days=config.getValue('options', 'defaultExpiration', 7)
            cutoff=now-datetime.timedelta(7, 0, 0)
            try:
                Post.table.update().where(sql.and_(Post.important==False,
                                                 Post.feed==self,
                                                 Post.date<cutoff)).\
                                    values(deleted=True).execute()
                elixir.session.commit()
            except:
                elixir.session.rollback()
        elif self.archiveType==1: #keepall
            return
        elif self.archiveType==2: #limitCount
            # FIXME: implement quicker!
            # Doesn't seem to work
            try:
                for post in self.posts[self.limitCount:]:
                    if post.important:
                        continue # Don't delete important stuff
                    post.deleted=True
                elixir.session.commit()
            except:
                elixir.session.rollback()

        elif self.archiveType==3: #limitDays
            # Tested
            cutoff=now-datetime.timedelta(self.limitDays, 0, 0)
            try:
                Post.table.update().where(sql.and_(Post.important==False,
                                                  Post.date<cutoff)).\
                                    values(deleted=True).execute()
                elixir.session.commit()
            except:
                elixir.session.rollback()
        elif self.archiveType==4: #no archiving
            try:
                Post.table.update().where(sql.and_(Post.important==False,
                                                  Post.feed==self)).\
                                    values(deleted=True).execute()
                elixir.session.commit()
            except:
                elixir.session.rollback()

        if expunge:
            # Delete all posts with deleted==True, which are not fresh
            # (are not in the last RSS/Atom we got)
            try:
                Post.table.delete().where(sql.and_(Post.deleted==True,
                                                   Post.fresh==False,
                                                   Post.feed==self)).execute()
                elixir.session.commit()
            except:
                elixir.session.rollback()

        # Force recount
        self.curUnread=-1
        self.unreadCount()