-
Notifications
You must be signed in to change notification settings - Fork 3
/
dh_test.py
43 lines (35 loc) · 1.17 KB
/
dh_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
__author__ = 'michbil'
import os
from twisted.python import log
from twisted.internet import reactor
from zope.interface import implements
from ConfigParser import ConfigParser as Conf
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import devicehive
import devicehive.poll
import devicehive.testfactory
import devicehive.ws
import devicehive.auto
import devicehive.device.ws
import devicehive.interfaces
import threading
import signal
def finishcallable():
print "Callallble on exit called"
close_port()
solar.disconnect()
from abisolar.abisolar import *
from net_engine.devhive_connection import SolarApp, SolarInfo
if __name__ == '__main__':
log.startLogging(sys.stdout)
# read conf-file
conf = Conf()
conf.read(os.path.join(os.path.dirname(__file__), os.path.splitext(os.path.basename(__file__))[0] + '.cfg'))
# create device-delegate instance
solar = SolarApp(conf)
solar_factory = devicehive.testfactory.TestFactory(solar)
solar_factory.connect('http://kidgo.com.ua:8080/DeviceHiveJava/rest')
reactor.addSystemEventTrigger('before', 'shutdown', finishcallable)
reactor.run()