Exemplo n.º 1
0
    def __init__(self):
        self.devices = devices.Devices()

        self.lh = -1
        self.lm = -1
        self.ltm = -1
        self.lum = -1
        self.time_update = 0
        self.btn_val = 1
        self.joy_val = 500
        self.edit_temp = 0
        self.state = 1  # 0-sleep, 1 - display, 2 - edit
        self.disp_state = 0
        self.lcd_state = 0
        self.edit_state = 0
        self.curr_temp = 0

        self.btn_task = None
        self.joy_task = None
        self.display_task = None
        self.web_task = None
        self.timer_task = None
        self.wifi_task = None
        self.lcd_task = None
        self.thermo_task = None
Exemplo n.º 2
0
 def GET(self):
     global devices
     devices = devices_.Devices()
     #print devices.devices
     output = ''
     for device in devices.devices:
         #print device
         output += str(devices.devices[device].params(
         )) + '\n\n'  # + ': ' + devices.devices[device].channels
     output += ']'
     return output
Exemplo n.º 3
0
    def __init__(self, platform, name):
        self.mPlatform = platform
        self.appNane = name

        strtime = time.strftime("_%Y_%m_%d_%H_%M_%S")
        self.dir = self.appNane + strtime
        os.mkdir(self.dir)

        self.mDevice = devices.Devices(self.mPlatform).get_device()
        self.mCon = connector.Connector('localhost', 8084)
        # self.eventsXML = xmls.EventsXML(self.mCon)
        # self.countersXML = xmls.CountersXML(self.mCon)
        self.capturedXML = xmls.CapturedXML(self.mCon)
        self.sessionXML = xmls.SessionXML(self.mCon)
        self.mAPC = apc.Apc(self.mCon, self.dir, '0000000000')
        self.mBuf = buffer.Buffer(self.mDevice, self.mCon, self.mAPC, self.capturedXML)
        self.mXls = xls.Xls(self.dir, 'Calc.xlsx', self.mDevice)
        self.status = -1

        for i in range(14):
            self.chkstatus.append(1)
Exemplo n.º 4
0
def _redirect():
    """
    Worker redirect to all operations on the DB tables.

    Operates the DB on table specified, for list, add, modify and delete registers.

    It uses the local static variables of the ``worker.py`` script as ``NETOR_HOME_DIRECTORY`` and ``DB_PATH_NAME``,
    unless a full path name to a TinyDB database is specified.

    It supports the following parameters:

    1. specifying operations:

       - l (list)
       - a (add)
       - m (modify)
       - d (delete)

    2. table to operate with

       - customer
       - sites
       - devices

    3. specifying DB full path name

    Example:
    ``../tinydb/scripts/worker.py -l customers /full/path/name/database.json``

    Logging to file ./log/tinydb.log

    :return: nothing
    """

    netorconf.check_netor_config(_NETOR_HOME_DIRECTORY)
    config = configparser.ConfigParser(
        interpolation=configparser.ExtendedInterpolation())
    config.read((_NETOR_HOME_DIRECTORY + "netor/netor.config"))
    tinydb_log_file = config['TinyDB']['tinydb_log_file']

    if (len(sys.argv) == 0) or len(sys.argv) > 4:
        print("\nInvalid parameters. Admin -operation tablename dbfile\n")
        return
    else:
        option = sys.argv[1]
        table = sys.argv[2]

    if len(sys.argv) == 4:
        if os.path.isfile((sys.argv[3])):
            print("Using specified DB file: " + sys.argv[3])
            db_path_name = sys.argv[3]
        else:
            print("DB path or file not found")
            return
    elif len(sys.argv) == 3:
        db_path_name = _DB_PATH_NAME
        print("\nUsing script default DB File: " + db_path_name + "\n")
    else:
        print("\nInvalid parameters. Admin -operation tablename\n")
        return

    if table == "customers":
        x = customers.Customers(db_path_name)
    elif table == "sites":
        x = sites.Sites(db_path_name)
    elif table == "devices":
        x = devices.Devices(db_path_name)
    else:
        print("Invalid table name")
        return

    if option == "-l":
        item = x.list()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" listed")
    elif option == "-a":
        item = x.add()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" added \"" + item + "\"")
    elif option == "-m":
        item = x.modify()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" modified: \"" + item[0] + "\" to \"" + item[1] + "\"")
    elif option == "-d":
        item = x.delete()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" deleted \"" + item + "\"")
    else:
        print("Invalid class operation")
 def operationUpdate(self, ip, community, version):
     temp_update = devices.Devices()
     self.result_Speed = temp_update.walkthrongh(ip, self.IFSPEED)
     self.result_Admin = temp_update.walkthrongh(ip, self.IFADMINSTATUS)
     self.result_Opera = temp_update.walkthrongh(ip, self.IFOPERSTATUS)
Exemplo n.º 6
0
scheduler = BackgroundScheduler(executors=executors,
                                timezone='MST',
                                job_defaults=job_defaults)

app = Flask(__name__)

gp.init()
adb = auto_adb()
# 公用类
pf = publicFunction.PublicFuncation()
# 添加类
addClass = add.Add()
# 登陆等类
loginClass = login.Login()
# 设备入库类
devicesClass = devices.Devices()
# 检测设备
ddUtils = dDU.DetectionDevicesUtils()
"""
    检测设备是否连接
        返回一个字典数据(key: 设备号   value: d)
"""
phoneMap = adb.test_device_usb()
"""
    定时检测 设备
"""


def schedulerDetection():
    phoneSet = ddUtils.detectionDevices()
    dataInfo = {}
Exemplo n.º 7
0
 def __init__(self):
     self.mysqlUtil = sqlUtils.SqlUtils()
     self.pf = publicFunction.PublicFuncation()
     self.devices = devices.Devices()
Exemplo n.º 8
0
 def __init__(self):
     self.devices = devices.Devices()
Exemplo n.º 9
0
 def GET(self, phone):
     global devices
     devices = devices_.Devices()
     return str(devices.channel(phone).params())
Exemplo n.º 10
0
 def GET(self, device_id):
     global devices
     devices = devices_.Devices()
     channels = devices.select(int(device_id)).params()
     return str(channels)
Exemplo n.º 11
0
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import web, devices as devices_, esl

urls = (
    '/devices',
    'list_devices',
    '/device/(.*)',
    'get_device',
    '/channel/(.*)',
    'get_channel',
)

app = web.application(urls, globals())
devices = devices_.Devices()


class list_devices:
    def GET(self):
        global devices
        devices = devices_.Devices()
        #print devices.devices
        output = ''
        for device in devices.devices:
            #print device
            output += str(devices.devices[device].params(
            )) + '\n\n'  # + ': ' + devices.devices[device].channels
        output += ']'
        return output
        #del devices
Exemplo n.º 12
0
import scanner
from parse import Parser
from names import Names
from network import Network
from monitors import Monitors
import devices
import sys

my_names=Names()
my_scanner=scanner.Scanner(sys.argv[1], my_names)
# my_scanner=scanner.Scanner("connectioninputconnected.txt", my_names)
my_devices=devices.Devices(my_names)
my_network=Network(my_names, my_devices)
my_monitors=Monitors(my_names, my_devices, my_network)
my_parser=Parser(my_names, my_devices, my_network, my_monitors, my_scanner)
print(my_parser.parse_network())