-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (42 loc) · 1.2 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import ConfigParser
import time
import liblo
import json
import sys
from codes.froxy import *
try:
server = liblo.Server(12345)
except liblo.ServerError, err:
print str(err)
sys.exit()
try:
target = liblo.Address(12346)
except liblo.AddressError, err:
print str(err)
sys.exit()
config = ConfigParser.ConfigParser()
config.read("froxy.conf")
filename_miner = ( "config/miner_linux.conf" if config.get("main","os") == "linux" else "config/miner_win.conf" )
froxy = Froxy(config, filename_miner)
froxy.prepare_miners()
def list_miner(path,args):
output = froxy.get_miners()
print output
liblo.send(target,"/web/miner/list",json.dumps(output))
def get_status(path,args):
print path, args
output = ""
#if miner.get_status_api():
# output = miner.get_summary()
#liblo.send(target,"/web/miner/status",output)
def stop_miner(path,args):
print "stop"
def start_miner(path,args):
print "start"
server.add_method("/miner/list", '', list_miner)
server.add_method("/miner/status", 'i', get_status)
server.add_method("/miner/stop", 'i', stop_miner)
server.add_method("/miner/start", 'i', start_miner)
froxy.start_miner()
while True:
server.recv(100)