-
Notifications
You must be signed in to change notification settings - Fork 1
/
cpb_client.py
executable file
·98 lines (73 loc) · 2.87 KB
/
cpb_client.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python3
"""Send an OSC message to capinibal"""
# see http://das.nasophon.de/pyliblo/examples.html
import liblo, sys, argparse
import pandas as pd
import time
parser = argparse.ArgumentParser(description='Send an OSC message to capinibal.')
parser.add_argument('--host', help='IP Address', default='127.0.0.1')
parser.add_argument('--port', help='Port', default='1234')
parser.add_argument('-s', '--speed', help='Speed of change (changes per second)')
parser.add_argument('-i', '--increase', help='Increase Speed of change')
parser.add_argument('-d', '--decrease', help='Decrease Speed of change')
parser.add_argument('-v', '--verbose', action='store_true', help='Enable debug output (default: off)')
args = parser.parse_args()
if (args.verbose):
print (args)
ip_address = args.host
port = int(args.port)
speed = inc = dec = None
if args.speed is not None:
speed=float(args.speed)
elif args.increase is not None:
inc=int(args.increase)
elif args.decrease is not None:
dec=int(args.decrease)
if (args.verbose):
print (speed, inc, dec)
try:
target = liblo.Address(ip_address, port)
except (liblo.AddressError, err):
print (str(err))
sys.exit()
if speed is not None:
# send message "/cpb/speed" with float argument
print ("Send speed", speed)
liblo.send(target, "/cpb/speed", speed)
sys.exit()
while (True):
# ~ dataframes = pd.read_html('http://bourse.latribune.fr/indices.html')
# ~ df1 = dataframes[2]
# ~ total_var_french_stock = 0;
# ~ for var in df1 ['Variation %']:
# ~ total_var_french_stock += float(var[:-1].replace(',', '.')) # 0,5% ---> 0.5
# ~ print ('var', var, '\ttotal var', total_var_french_stock)
# ~ if (total_var_french_stock >= 0):
# ~ inc = int(total_var_french_stock * 10 )
# ~ else :
# ~ dec = int(-total_var_french_stock * 10 )
# ~ dataframes = pd.read_html('https://fr.wikipedia.org/wiki/Sp%C3%A9cial:Statistiques')
# ~ print (dataframes)
# ~ df1 = dataframes[2]
# ~ total_var_french_stock = 0;
# ~ for var in df1 ['Variation %']:
# ~ total_var_french_stock += float(var[:-1].replace(',', '.')) # 0,5% ---> 0.5
# ~ print ('var', var, '\ttotal var', total_var_french_stock)
# ~ if (total_var_french_stock >= 0):
# ~ inc = int(total_var_french_stock * 10 )
# ~ else :
# ~ dec = int(-total_var_french_stock * 10 )
# send message to given port on specified host
if inc is not None:
# send message "/cpb/increase" with int argument
print ("Send inc", inc)
liblo.send(target, "/cpb/increase", inc)
elif dec is not None:
# send message "/cpb/decrease" with int argument
print ("Send dec", dec)
liblo.send(target, "/cpb/decrease", dec)
else:
print ("Nothing happend !!!")
# ~ parser.print_help()
# Wait for 45 seconds
time.sleep(45)