Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-24fa
project03
Commits
64fa21a1
Commit
64fa21a1
authored
6 months ago
by
Adam Blank
Browse files
Options
Download
Email Patches
Plain Diff
Update transfer.py
parent
1b586cc6
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
transfer.py
+17
-26
transfer.py
with
17 additions
and
26 deletions
+17
-26
transfer.py
View file @
64fa21a1
import
subprocess
import
time
import
platform
import
shutil
import
os
import
ports
import
psutil
import
urllib.request
import
ssl
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
import
os
import
shutil
import
platform
import
time
from
pathlib
import
Path
import
subprocess
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
def
get_drive
():
...
...
@@ -52,36 +52,27 @@ if not trinkey:
print
(
"Could not find the Trinkey to connect to...try removing it from the USB drive and plugging it back in."
)
exit
(
1
)
# Kill any running program
trinkey
.
write
(
bytes
(
chr
(
0x03
),
'utf-8'
))
trinkey
.
flush
()
print
(
"Connected to Trinkey! Transfering files..."
)
shutil
.
rmtree
(
os
.
path
.
join
(
'src'
,
'__pycache__'
),
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
'support'
,
'__pycache__'
),
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
disk
,
'__pycache__'
),
True
)
for
x
in
os
.
listdir
(
disk
):
try
:
os
.
unlink
(
os
.
path
.
join
(
disk
,
x
))
except
(
PermissionError
,
FileNotFoundError
,
OSError
):
pass
shutil
.
rmtree
(
disk
,
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
disk
,
'lib'
),
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
disk
,
'src'
),
True
)
shutil
.
copytree
(
'src'
,
os
.
path
.
join
(
disk
,
'src'
),
dirs_exist_ok
=
True
)
shutil
.
rmtree
(
os
.
path
.
join
(
disk
,
'support'
),
True
)
shutil
.
copytree
(
'support'
,
os
.
path
.
join
(
disk
,
'support'
),
dirs_exist_ok
=
True
)
shutil
.
copy
(
'code.py'
,
os
.
path
.
join
(
disk
,
'code.py'
))
# Kill any running program
trinkey
.
write
(
bytes
(
chr
(
0x03
),
'utf-8'
))
trinkey
.
flush
()
Path
(
os
.
path
.
join
(
disk
,
'code.py'
)).
write_bytes
(
Path
(
"code.py"
).
read_bytes
())
print
(
"Files transfered...connecting to Trinkey..."
)
time
.
sleep
(
1
)
trinkey
.
flush
()
time
.
sleep
(
5
)
print
(
"Restarting Trinkey!"
)
# Kill any running program
trinkey
.
write
(
bytes
(
chr
(
0x04
),
'utf-8'
))
trinkey
.
flush
()
time
.
sleep
(
1
)
miniterm
=
ports
.
connect_to_serial
(
trinkey
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help