Skip to content
Snippets Groups Projects
Commit 4e79b9c9 authored by Köllőd Csaba's avatar Köllőd Csaba
Browse files

Update: Language

- switching to english and rename file
parent a38a7d93
No related branches found
No related tags found
No related merge requests found
from downloadFilesOfNeuroFlowDevice import download_data from file_downloader import download_data
from merge_records import process_data_files_in_dir from merge_records import process_data_files_in_dir
from gui import show_message, select_folder_in_explorer from gui import show_message, select_folder_in_explorer
...@@ -13,7 +13,7 @@ def main(): ...@@ -13,7 +13,7 @@ def main():
) )
show_message('Give credentials in terminal!', TITLE) show_message('Give credentials in terminal!', TITLE)
path = download_data(path) path = download_data(path)
out_file = input('Type output file format ( edf / fif ) ') out_file = input('Select output file format ( edf / fif ) ')
process_data_files_in_dir(path, out_file) process_data_files_in_dir(path, out_file)
print(f'Processed files are available in {path}') print(f'Processed files are available in {path}')
......
...@@ -5,43 +5,43 @@ from pathlib import Path ...@@ -5,43 +5,43 @@ from pathlib import Path
import requests import requests
class tcolors: class Colors:
HEADER = '\033[93m' HEADER = '\033[93m'
OK = '\033[92m' OK = '\033[92m'
FAIL = '\033[91m' FAIL = '\033[91m'
ENDC = '\033[0m' END = '\033[0m'
def download_data(path='.'): def download_data(path='.'):
path = Path(path) path = Path(path)
print("\n" + tcolors.HEADER + "================================" + tcolors.ENDC) print(f'\n{Colors.HEADER}================================{Colors.END}')
print(tcolors.HEADER + "NeuroFlow Lab Kutatói Alkalmazás" + tcolors.ENDC) print(f'{Colors.HEADER}NeuroFlow Lab File Downloader{Colors.END}')
print(tcolors.HEADER + "================================" + tcolors.ENDC + "\n") print(f'{Colors.HEADER}================================{Colors.END}\n')
email = input("Kutató email címe: ") email = input("email address: ")
password = getpass("Kutató jelszava: ") password = getpass("password: ")
deviceID = input("Eszköz egyedi azonosítója: ") device_id = input("NeuroFlow device ID: ")
path = path.joinpath(deviceID) path = path.joinpath(device_id)
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}
payload = {'email': email, 'password': password, 'deviceID': deviceID} payload = {'email': email, 'password': password, 'deviceID': device_id}
r = requests.post('https://europe-west3-neuroflowtest.cloudfunctions.net/testListFilesByScript', headers=headers, r = requests.post('https://europe-west3-neuroflowtest.cloudfunctions.net/testListFilesByScript', headers=headers,
data=json.dumps(payload)) data=json.dumps(payload))
if r.status_code == 200: if r.status_code == 200:
listOfFiles = r.json()['files'] list_of_files = r.json()['files']
print(f'\nLe fogok tölteni {len(listOfFiles)} darab fájl-t a {path} könyvtárba...') print(f'\n{len(list_of_files)} files will be downloaded to {path}')
if not path.exists(): if not path.exists():
path.mkdir(parents=True, exist_ok=True) path.mkdir(parents=True, exist_ok=True)
print(tcolors.OK + "Létrehoztam a '" + str(path) + "' könytárat." + tcolors.ENDC) print(f'{Colors.OK}{path} was created{Colors.END}')
print("") print("")
for i, file in enumerate(listOfFiles): for i, file in enumerate(list_of_files):
print("Indítom a '" + file + "' nevű fájl letöltését...") print(f'Downloading file {file}')
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}
payload = {'email': email, 'password': password, 'deviceID': deviceID, 'fileName': file} payload = {'email': email, 'password': password, 'deviceID': device_id, 'fileName': file}
r = requests.post('https://europe-west3-neuroflowtest.cloudfunctions.net/testDownloadByScript', r = requests.post('https://europe-west3-neuroflowtest.cloudfunctions.net/testDownloadByScript',
headers=headers, data=json.dumps(payload)) headers=headers, data=json.dumps(payload))
...@@ -50,18 +50,19 @@ def download_data(path='.'): ...@@ -50,18 +50,19 @@ def download_data(path='.'):
with open(save_path, "wb") as binary_file: with open(save_path, "wb") as binary_file:
binary_file.write(r.content) binary_file.write(r.content)
print(tcolors.OK + "LETÖLTVE" + tcolors.ENDC, f'{100. * i / len(listOfFiles):.2f} %') print(f'{Colors.OK}DONE{Colors.END} {100. * (i + 1) / len(list_of_files):.2f} %')
else: else:
print(tcolors.FAIL + "HIBA" + tcolors.ENDC) print(f'{Colors.FAIL}ERROR{Colors.END}')
print( print(f'Files, corresponding to device {device_id} are stored in {device_id} folder.\n')
"\nA '" + deviceID + "' eszközhöz tartozó fájlok letöltésre kerültek a '" + deviceID + "' nevű könyvtárba.\n") return path
elif r.status_code in (401, 444, 445): elif r.status_code in (401, 444, 445):
print("\n" + tcolors.FAIL + "Hibás email cím vagy jelszó!" + tcolors.ENDC + "\n") print(f'\n{Colors.FAIL}Wrong email or password!{Colors.END}\n')
elif r.status_code == 446: elif r.status_code == 446:
print("\n" + tcolors.FAIL + "Hibás eszköz azonosító!" + tcolors.ENDC + "\n") print(f'\n{Colors.FAIL}Wrong device ID!{Colors.END}\n')
return path
exit()
if __name__ == '__main__': if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment