コード例 #1
0
ファイル: startup.py プロジェクト: patlmi/screenBloom
    def run(self):
        url = 'http://%s:5000/' % self.host
        print 'Welcome to ScreenBloom!'
        print 'Server running at: %s' % url
        if not self.stoprequest.isSet():
            # Check For DLL error
            if not utility.dll_check():
                url += 'dll-error'
            # Check if config file has been created yet
            elif os.path.isfile(utility.get_config_path()):
                print 'Config already exists'
                config = ConfigParser.RawConfigParser()
                config.read(utility.get_config_path())
                utility.write_config('App State', 'running', '0')

                # Wait for 200 status code from server then load up interface
                while not utility.check_server(self.host):
                    sleep(0.2)

                sb_controller.start()
            else:
                # Config file doesn't exist, open New User interface
                print 'Config does not exist yet!'
                url += 'new-user'

        webbrowser.open(url)
コード例 #2
0
    def run(self):
        base_url = 'http://%s:%d/' % (self.host, self.port)
        url = copy(base_url)
        print 'Welcome to ScreenBloom!'
        print 'Server running at: %s' % base_url
        presets.update_presets_if_necessary()

        if not self.stoprequest.isSet():
            # Startup checks
            if params.BUILD == 'win':
                # Check For DLL error
                if not utility.dll_check():
                    url = base_url + 'dll-error'
            # Check if config file has been created yet
            if os.path.isfile(utility.get_config_path()):
                # Check to see if config needs to be updated
                if not utility.config_check():
                    url = base_url + 'update-config'
                else:
                    # Init Screen object
                    sb_controller.init()
            else:
                # Config file doesn't exist, open New User interface
                print 'Redirecting to New User interface...'
                url = base_url + 'new-user'

        # Wait for 200 status code from server then load up interface
        while not utility.check_server(self.host, self.port):
            sleep(0.2)

        webbrowser.open(url)
コード例 #3
0
ファイル: startup.py プロジェクト: digiltd/screenBloom
    def startup_checks(self):
        # Check For DLL error
        if params.BUILD == 'win':
            if not utility.dll_check():
                self.url = self.base_url + 'dll-error'
                self.error = True
                return

        # Check if config file has been created yet
        if os.path.isfile(utility.get_config_path()):
            # Check to see if config needs to be updated
            if not utility.config_check():
                self.url = self.base_url + 'update-config'
                self.needs_update = True
                return
            else:
                presets.update_presets_if_necessary()
                config = utility.get_config_dict()
                lights_initial_state = json.dumps(utility.get_hue_initial_state(config['ip'], config['username']))

                # Init Screen object with some first-run defaults
                utility.write_config('App State', 'running', False)
                utility.write_config('Light Settings', 'default', lights_initial_state)
                sb_controller.init()

                self.url = self.base_url
                return
        else:
            # Config file doesn't exist, open New User interface
            self.url = self.base_url + 'new-user'
            self.new_user = True
            return
コード例 #4
0
ファイル: sb_controller.py プロジェクト: zim514/screenBloom
from func_timer import func_timer
from config import params
from time import sleep
import hue_interface
import threading
import urllib2
import utility
import random
import json
import ast

if utility.dll_check():
    import img_proc


# Class for running ScreenBloom thread
class ScreenBloom(threading.Thread):
    def __init__(self, update):
        super(ScreenBloom, self).__init__()
        self.stoprequest = threading.Event()
        self.update = float(update)

    def run(self):
        while not self.stoprequest.isSet():
            run()
            sleep(.1)

    def join(self, timeout=None):
        self.stoprequest.set()
        super(ScreenBloom, self).join(timeout)
コード例 #5
0
ファイル: sb_controller.py プロジェクト: digiltd/screenBloom
from beautifulhue.api import Bridge
from func_timer import func_timer
from time import sleep
import hue_interface
import threading
import urllib2
import utility
import random
import json
import ast

if utility.dll_check():
    import img_proc


# Class for running ScreenBloom thread
class ScreenBloom(threading.Thread):
    def __init__(self, update):
        super(ScreenBloom, self).__init__()
        self.stoprequest = threading.Event()
        self.update = float(update)

    def run(self):
        while not self.stoprequest.isSet():
            run()
            sleep(.1)

    def join(self, timeout=None):
        self.stoprequest.set()
        super(ScreenBloom, self).join(timeout)