-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsys_manager.py
101 lines (90 loc) · 2.7 KB
/
sys_manager.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
99
100
101
import threading
import requests
import time
import os
import tradingview_ws
from tradingview_ta import TA_Handler, Interval, Exchange
from wifi import Cell, Scheme
import subprocess
import socket
has_internet = True
eth_price = {'symbol': 'ETHUSD', 'price': 0, 'prev_price': 0}
prev_price = 0
wifi_ssid = "Unknown"
wifi_ip = ""
wifi_host = ""
def callbackFunc(s):
eth = TA_Handler(
symbol="ETHUSDT",
screener="crypto",
exchange="COINBASE",
interval=Interval.INTERVAL_4_HOURS
)
print(eth.get_analysis().summary)
reco = eth.get_analysis().summary
indicators = eth.get_analysis().indicators
print(reco, type(reco))
print(indicators['open'])
print("Tradingview call back")
global eth_price
global prev_price
s["prev_price"] = prev_price
s["reco"] = reco['RECOMMENDATION']
s["open"] = indicators['open']
print(s)
eth_price = s
prev_price = s["price"]
def sub_eth_price():
print("Creating the tradingview thing")
# Example output: {"RECOMMENDATION": "BUY", "BUY": 8, "NEUTRAL": 6, "SELL": 3}
pair = "ETHUSD"
market = "crypto" # 'stock' | 'futures' | 'forex' | 'cfd' | 'crypto' | 'index' | 'economic'
username = None
password = None
trading = tradingview_ws.TradingViewWs(pair, market, username, password)
# get quote price
trading.realtime_quote(callbackFunc)
def screen_sleep():
global screen_on
screen_on = False
os.system('xset -display :0 dpms force off')
def screen_wake():
global screen_on
screen_on = True
os.system('xset -display :0 dpms force on')
def check_internet(request):
global has_internet
try:
result = request()
has_internet = True
except Exception as _:
print("no ints")
result = None
has_internet = False
return result
def get_wifi_networks():
get_wifi_ssid()
def get_wifi_ssid():
global has_internet
global wifi_ssid
global wifi_host
global wifi_ip
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(('192.255.255.255', 1))
IP = s.getsockname()[0]
output = subprocess.check_output(['iwgetid']).decode()
wifi_ssid = output.split('"')[1]
wifi_host = socket.gethostname()
wifi_ip = IP
has_internet = True
print("Your Computer Name is:"+wifi_host)
print("Your Computer IP Address is:"+wifi_ip)
print("Connected Wifi SSID: " + output.split('"')[1])
except Exception as e:
has_internet = False
print(e)
get_price = threading.Thread(target=sub_eth_price, name="GetPrice")
get_price.start()
get_wifi = threading.Thread(target=get_wifi_networks, name="get_wifi")
get_wifi.start()