示例#1
0
def main():
    dm = DeviceManager(None, None)
    automation = RemoteAutomation(dm)
    parser = RemoteOptions(automation)
    options, args = parser.parse_args()

    if (options.deviceIP == None):
        print "Error: you must provide a device IP to connect to via the --device option"
        sys.exit(1)

    dm = DeviceManager(options.deviceIP, options.devicePort)
    automation.setDeviceManager(dm)

    if (options.remoteProductName != None):
        automation.setProduct(options.remoteProductName)

    # Set up the defaults and ensure options are set
    options = parser.verifyRemoteOptions(options)
    if (options == None):
        print "ERROR: Invalid options specified, use --help for a list of valid options"
        sys.exit(1)

    automation.setAppName(options.app)
    automation.setRemoteProfile(options.remoteProfile)
    reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)

    # Start the webserver
    reftest.startWebServer(options)
    #an example manifest name to use on the cli
    #    manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
    reftest.runTests(args[0], options)
    reftest.stopWebServer(options)
示例#2
0
def main():
    dm_none = DeviceManager(None, None)
    automation = RemoteAutomation(dm_none)
    parser = RemoteOptions(automation)
    options, args = parser.parse_args()

    if (options.deviceIP == None):
        print "Error: you must provide a device IP to connect to via the --device option"
        sys.exit(1)

    dm = DeviceManager(options.deviceIP, options.devicePort)
    automation.setDeviceManager(dm)

    if (options.remoteProductName != None):
        automation.setProduct(options.remoteProductName)

    # Set up the defaults and ensure options are set
    options = parser.verifyRemoteOptions(options)
    if (options == None):
        print "ERROR: Invalid options specified, use --help for a list of valid options"
        sys.exit(1)

    parts = dm.getInfo('screen')['screen'][0].split()
    width = int(parts[0].split(':')[1])
    height = int(parts[1].split(':')[1])
    if (width < 1050 or height < 1050):
        print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height)
        sys.exit(1)

    automation.setAppName(options.app)
    automation.setRemoteProfile(options.remoteProfile)
    automation.setRemoteLog(options.remoteLogFile)
    reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)

    # Start the webserver
    reftest.startWebServer(options)

    # Hack in a symbolic link for jsreftest
    os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest")))

    # Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot
    manifest = args[0]
    if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])):
        manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + args[0]
    elif os.path.exists(args[0]):
        manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/')
        manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath

    procName = options.app.split('/')[-1]
    if (dm.processExist(procName)):
      dm.killProcess(procName)

#an example manifest name to use on the cli
#    manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
    reftest.runTests(manifest, options)
    reftest.stopWebServer(options)
示例#3
0
        eveapp.test_client().post(
            '/devices',
            data=json.dumps({
                'name':
                device,
                'queries': [
                    "_".join([device, query])
                    for query in devicemanager.get_queries(device)
                ]
            }),
            content_type='application/json')
        for query in devicemanager.get_queries(device):
            eveapp.test_client().post('/queries',
                                      data=json.dumps({
                                          'name':
                                          "_".join([device, query]),
                                          'device':
                                          device,
                                          'value':
                                          0
                                      }),
                                      content_type='application/json')


devices = DeviceManager(ConfigBundle("conf"))  # pylint: disable=invalid-name
pysattuner = Eve(settings='dev_settings.py')  # pylint: disable=invalid-name
spawn_device_resources(devices, pysattuner)

if __name__ == '__main__':
    pysattuner.run(host='0.0.0.0', port=5000, debug=True)
示例#4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from twisted.internet import reactor
from twisted.web import static, server
from twisted.web.resource import Resource

import logging
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)

from devicemanager import DeviceManager
devices = DeviceManager()

import sys


class WritableObject:
    def __init__(self):
        self.content = []

    def write(self, string):
        self.content.append(string)

    def dump(self):
        dump = self.content
        self.content = []
        return str(''.join(dump))


WritableObject = WritableObject()

示例#5
0
from devicemanager import DeviceManager
from device import Device

device1 = Device("Lamp 1", False)
device2 = Device("Lamp 2", False)
device3 = Device("Philips hue", True)
device4 = Device("Nest", False)

manager = DeviceManager()
manager.add_device(1, device1)
manager.add_device(2, device2)
manager.add_device(3, device3)
manager.add_device(4, device4)

manager.switch_everything_off()

for id, device in manager.device_dict.items():
    print(id)
    print(device)