Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MCC Flow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Köllőd Csaba
MCC Flow
Commits
9c76d60c
Commit
9c76d60c
authored
2 years ago
by
Köllőd Csaba
Browse files
Options
Downloads
Patches
Plain Diff
Update downloadFilesOfNeuroFlowDevice.py
parent
d98bd0f8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mcc-flow/downloadFilesOfNeuroFlowDevice.py
+14
-11
14 additions, 11 deletions
mcc-flow/downloadFilesOfNeuroFlowDevice.py
with
14 additions
and
11 deletions
mcc-flow/downloadFilesOfNeuroFlowDevice.py
+
14
−
11
View file @
9c76d60c
import
json
from
getpass
import
getpass
from
pathlib
import
Path
import
json
import
os
import
requests
...
...
@@ -12,7 +12,8 @@ class tcolors:
ENDC
=
'
\033
[0m
'
def
download_data
():
def
download_data
(
path
=
'
.
'
):
path
=
Path
(
path
)
print
(
"
\n
"
+
tcolors
.
HEADER
+
"
================================
"
+
tcolors
.
ENDC
)
print
(
tcolors
.
HEADER
+
"
NeuroFlow Lab Kutatói Alkalmazás
"
+
tcolors
.
ENDC
)
print
(
tcolors
.
HEADER
+
"
================================
"
+
tcolors
.
ENDC
+
"
\n
"
)
...
...
@@ -20,6 +21,7 @@ def download_data():
email
=
input
(
"
Kutató email címe:
"
)
password
=
getpass
(
"
Kutató jelszava:
"
)
deviceID
=
input
(
"
Eszköz egyedi azonosítója:
"
)
path
=
path
.
joinpath
(
deviceID
)
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
payload
=
{
'
email
'
:
email
,
'
password
'
:
password
,
'
deviceID
'
:
deviceID
}
...
...
@@ -28,14 +30,14 @@ def download_data():
if
r
.
status_code
==
200
:
listOfFiles
=
r
.
json
()[
'
files
'
]
print
(
"
\n
Le fogok tölteni
"
+
str
(
len
(
listOfFiles
)
)
+
"
darab fájl-t a
'"
+
deviceID
+
"'
nevű
könyvtárba...
"
)
print
(
f
'
\n
Le fogok tölteni
{
len
(
listOfFiles
)
}
darab fájl-t a
{
path
}
könyvtárba...
'
)
if
not
os
.
path
.
exists
(
deviceID
):
os
.
makedirs
(
deviceID
)
print
(
tcolors
.
OK
+
"
Létrehoztam a
'"
+
deviceID
+
"'
nevű
könytárat.
"
+
tcolors
.
ENDC
)
if
not
path
.
exists
():
path
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
print
(
tcolors
.
OK
+
"
Létrehoztam a
'"
+
str
(
path
)
+
"'
könytárat.
"
+
tcolors
.
ENDC
)
print
(
""
)
for
file
in
listOfFiles
:
for
i
,
file
in
enumerate
(
listOfFiles
)
:
print
(
"
Indítom a
'"
+
file
+
"'
nevű fájl letöltését...
"
)
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
...
...
@@ -44,11 +46,11 @@ def download_data():
headers
=
headers
,
data
=
json
.
dumps
(
payload
))
if
r
.
status_code
==
200
:
path
=
deviceID
+
'
/
'
+
file
with
open
(
path
,
"
wb
"
)
as
binary_file
:
save_
path
=
path
.
joinpath
(
file
)
with
open
(
save_
path
,
"
wb
"
)
as
binary_file
:
binary_file
.
write
(
r
.
content
)
print
(
tcolors
.
OK
+
"
LETÖLTVE
"
+
tcolors
.
ENDC
)
print
(
tcolors
.
OK
+
"
LETÖLTVE
"
+
tcolors
.
ENDC
,
f
'
{
100.
*
i
/
len
(
listOfFiles
)
:
.
2
f
}
%
'
)
else
:
print
(
tcolors
.
FAIL
+
"
HIBA
"
+
tcolors
.
ENDC
)
...
...
@@ -59,6 +61,7 @@ def download_data():
print
(
"
\n
"
+
tcolors
.
FAIL
+
"
Hibás email cím vagy jelszó!
"
+
tcolors
.
ENDC
+
"
\n
"
)
elif
r
.
status_code
==
446
:
print
(
"
\n
"
+
tcolors
.
FAIL
+
"
Hibás eszköz azonosító!
"
+
tcolors
.
ENDC
+
"
\n
"
)
return
path
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment