1234567891011121314151617181920212223242526272829303132333435363738394041 |
- from FTPModule import FTPS
- from threading import *
- import os
- from SysInfo import Informator
- import requests
- import time
- import config
- import random
- def read_authdata(filename):
- with open(filename,"r") as file:
- l = file.readline().split(",")
- print(l)
- return l
- l = read_authdata("authdata")
- print(l)
- user = l[0]
- passw= l [1]
- informator = Informator()
- ftps = FTPS(user,passw,str(os.getcwd())+"/storage/")
- def start_server():
- ftps.start_server(('127.0.0.1',21))
- def register_node():
- resp1 = requests.get(f"{config.coord_server}/reg?ip={informator.ip}&rg={informator.user_country}&u={user}&pass={passw}")
- print("REGISTRATION ",resp1.status_code)
- resp2 = requests.get(f"{config.coord_server}/update-info?ip={informator.ip}&rg={informator.user_country}&free_space={informator.getFreeDiskSpace()}")
- print("UPDATE ",resp2.status_code)
- def update_info():
- while True:
- time.sleep(15)
- resp2 = requests.get(f"{config.coord_server}/update-info?ip={informator.ip}&rg={informator.user_country}&free_space={informator.getFreeDiskSpace()}")
- print("UPDATE ", resp2.status_code)
- if __name__=="__main__":
- register_node()
- thread_update_info = Thread(target=update_info)
- thread_ftps = Thread(target=start_server)
- thread_ftps.start()
- thread_update_info.start()
|