@@ -20,7 +20,6 @@ See `armk-init --help` for CLI arguments
20
20
from __future__ import print_function
21
21
import os
22
22
import argparse
23
- from clint .textui import prompt , validators , colored , puts
24
23
25
24
## Global Vars
26
25
VERSION = "1.0"
@@ -56,6 +55,14 @@ PARSER.add_argument('-t', '--template', action='store_true',
56
55
help = 'create bare minimum Arduino source file' )
57
56
ARGS = PARSER .parse_args ()
58
57
58
+ try :
59
+ from clint .textui import prompt , validators
60
+ except ImportError :
61
+ if not ARGS .quiet :
62
+ print ("Python module 'clint' is required for running prompted. Install the module or run with arguments only using --quiet" )
63
+ quit ()
64
+
65
+
59
66
def generate_makefile ():
60
67
"""
61
68
Generate the Makefile content using prompts or parsed arguments
@@ -65,8 +72,8 @@ def generate_makefile():
65
72
66
73
# Basic
67
74
if not ARGS .quiet :
68
- puts ( colored . cyan ("Generating Arduino Ard-Makefile project in "
69
- + os .path .abspath (ARGS .directory )))
75
+ print ("Generating Arduino Ard-Makefile project in "
76
+ + os .path .abspath (ARGS .directory ))
70
77
btag = prompt .query ('Board tag?' , default = 'uno' )
71
78
if btag != 'uno' :
72
79
bsub = prompt .query ('Board sub micro?' , default = 'atmega328' )
@@ -188,27 +195,27 @@ def write_to_makefile(file_content, path):
188
195
Write the Makefile file
189
196
"""
190
197
makefile = open (path + "Makefile" , 'w' )
191
- puts ( colored . cyan ( "Writing Makefile..." ) )
198
+ print ( "Writing Makefile..." )
192
199
if ARGS .verbose :
193
- puts ( colored . yellow ( file_content ) )
200
+ print ( file_content )
194
201
makefile .write (file_content )
195
202
makefile .close ()
196
203
197
204
def write_template (filename ):
198
205
"""
199
206
Write template Arduino .ino source
200
207
"""
201
- puts ( colored . cyan ( "Writing " + os .path .abspath (filename ) + ".ino..." ) )
208
+ print ( "Writing " + os .path .abspath (filename ) + ".ino..." )
202
209
if os .path .isfile (filename + '.ino' ):
203
210
if ARGS .quiet :
204
- puts ( colored . red ( filename + '.ino' + ' already exists! Stopping.' ) )
211
+ print ( filename + '.ino' + ' already exists! Stopping.' )
205
212
return
206
- puts ( colored . red ( filename + '.ino' + ' already exists! Overwrite?' ) )
213
+ print ( filename + '.ino' + ' already exists! Overwrite?' )
207
214
if prompt .yn ('Continue?' , default = 'n' ):
208
215
return
209
216
src = open ((filename + ".ino" ), 'w' )
210
217
if ARGS .verbose :
211
- puts ( colored . yellow ( ARD_TEMPLATE ) )
218
+ print ( ARD_TEMPLATE )
212
219
src .write ("/* Project: " + filename + " */\n " + ARD_TEMPLATE )
213
220
src .close ()
214
221
@@ -218,7 +225,7 @@ def check_create_folder(folder):
218
225
"""
219
226
if folder and not folder == 'AUTO' :
220
227
if not os .path .exists (folder ):
221
- puts ( colored . cyan (( "Creating " + os .path .abspath (folder ) + " folder" )) )
228
+ print ( "Creating " + os .path .abspath (folder ) + " folder" )
222
229
os .makedirs (folder )
223
230
224
231
def check_define (define , user ):
@@ -241,13 +248,13 @@ if __name__ == '__main__':
241
248
os .chdir (ARGS .directory )
242
249
if os .path .isfile ('Makefile' ):
243
250
if ARGS .quiet :
244
- puts ( colored . red ('Makefile in ' + os .path .abspath (ARGS .directory )
245
- + ' already exists! Stopping.' ))
251
+ print ('Makefile in ' + os .path .abspath (ARGS .directory )
252
+ + ' already exists! Stopping.' )
246
253
quit ()
247
254
248
255
# Confirm with user if not quiet mode
249
- puts ( colored . red ('Makefile in ' + os .path .abspath (ARGS .directory )
250
- + ' already exists! Overwrite?' ))
256
+ print ('Makefile in ' + os .path .abspath (ARGS .directory )
257
+ + ' already exists! Overwrite?' )
251
258
if prompt .yn ('Continue?' , default = 'n' ):
252
259
quit ()
253
260
# Run it
0 commit comments