|
@@ -1,52 +0,0 @@
|
1
|
|
-#
|
2
|
|
-# upload_prompt_extra_script.py
|
3
|
|
-# set the output_port
|
4
|
|
-#
|
5
|
|
-from __future__ import print_function
|
6
|
|
-
|
7
|
|
-has_tkinter = False
|
8
|
|
-try:
|
9
|
|
- import sys
|
10
|
|
- if sys.version_info[0] < 3:
|
11
|
|
- import Tkinter as tk
|
12
|
|
- import tkFileDialog as fileDialog
|
13
|
|
- from Tkinter import Tk
|
14
|
|
- else:
|
15
|
|
- import tkinter as tk
|
16
|
|
- from tkinter import Tk
|
17
|
|
- from tkinter import filedialog as fileDialog
|
18
|
|
- has_tkinter = True
|
19
|
|
-except:
|
20
|
|
- pass
|
21
|
|
-
|
22
|
|
-import pioutil
|
23
|
|
-if has_tkinter and pioutil.is_pio_build():
|
24
|
|
-
|
25
|
|
- Import("env")
|
26
|
|
-
|
27
|
|
- def print_error(e):
|
28
|
|
- print('\nUnable to find destination disk (%s)\n' %( e ) )
|
29
|
|
-
|
30
|
|
- def before_upload(source, target, env):
|
31
|
|
- #
|
32
|
|
- # Find a disk for upload
|
33
|
|
- #
|
34
|
|
- upload_disk = ''
|
35
|
|
-
|
36
|
|
- root = Tk() # pointing root to Tk() to use it as Tk() in program.
|
37
|
|
- root.withdraw() # Hides small tkinter window.
|
38
|
|
-
|
39
|
|
- root.attributes('-topmost', True) # Opened windows will be active. above all windows despite of selection.
|
40
|
|
-
|
41
|
|
- upload_disk = fileDialog.askdirectory(title="Select the root of your SDCARD") # Returns opened path as str
|
42
|
|
- if not upload_disk:
|
43
|
|
- print_error('Canceled')
|
44
|
|
- return
|
45
|
|
- else:
|
46
|
|
- env.Replace(
|
47
|
|
- UPLOAD_FLAGS="-P$UPLOAD_PORT"
|
48
|
|
- )
|
49
|
|
- env.Replace(UPLOAD_PORT=upload_disk)
|
50
|
|
- print('\nUpload disk: ', upload_disk, '\n')
|
51
|
|
-
|
52
|
|
- env.AddPreAction("upload", before_upload)
|