Prusa MINI Firmware overview
auto_build Namespace Reference

Classes

class  output_window
 

Functions

def get_answer (board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt)
 Python 2 error messages: Can't find a usable init.tcl in the following directories ... More...
 
def resolve_path (path)
 
def open_file (path)
 
def get_build_last ()
 
def get_board_name ()
 
def get_env_from_line (line, start_position)
 
def get_starting_env (board_name_full, version)
 
def get_CPU_name (environment)
 
def get_env (board_name, ver_Marlin)
 
def write_to_screen_queue (text, format_tag='normal')
 
def line_print (line_input)
 
def sys_PIO ()
 
def run_PIO (dummy)
 
def main ()
 

Variables

 pwd = os.getcwd()
 
 num_args = len(sys.argv)
 
 build_type = str(sys.argv[1])
 
 python_ver = sys.version_info[0]
 
 current_OS = platform.system()
 
string target_env = ''
 
string board_name = ''
 
 IO_queue = queue.Queue()
 
bool warning = False
 
bool warning_FROM = False
 
bool error = False
 
bool standard = True
 
bool prev_line_COM = False
 
bool next_line_warning = False
 
bool warning_continue = False
 
int line_counter = 0
 
 que = queue.Queue()
 

Function Documentation

◆ get_answer()

def auto_build.get_answer (   board_name,
  cpu_label_txt,
  cpu_a_txt,
  cpu_b_txt 
)

Python 2 error messages: Can't find a usable init.tcl in the following directories ...

error "invalid command name "tcl_findLibrary""

Fix for the above errors on my Win10 system: search all init.tcl files for the line "package require -exact Tcl" that has the highest 8.5.x number copy it into the first directory listed in the error messages set the environmental variables TCLLIBPATH and TCL_LIBRARY to the directory where you found the init.tcl file reboot popup to get input from user

129 def get_answer(board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt):
130 
131 
132  if python_ver == 2:
133  import Tkinter as tk
134  else:
135  import tkinter as tk
136 
137  def CPU_exit_3(): # forward declare functions
138 
139  CPU_exit_3_()
140  def CPU_exit_4():
141 
142  CPU_exit_4_()
143  def kill_session():
144  kill_session_()
145 
146  root_get_answer = tk.Tk()
147  root_get_answer.attributes("-topmost", True)
148 
149  root_get_answer.chk_state_1 = 1 # declare variables used by TK and enable
150 
151  chk_state_1 = 0 # set initial state of check boxes
152 
153 
154  global get_answer_val
155  get_answer_val = 2 # return get_answer_val, set default to match chk_state_1 default
156 
157 
158  l1 = tk.Label(text=board_name,
159  fg = "light green",
160  bg = "dark green",
161  font = "Helvetica 12 bold").grid(row=1)
162 
163  l2 = tk.Label(text=cpu_label_txt,
164  fg = "light green",
165  bg = "dark green",
166  font = "Helvetica 16 bold italic").grid(row=2)
167 
168  b4 = tk.Checkbutton(text=cpu_a_txt,
169  fg = "black",
170  font = "Times 20 bold ",
171  variable=chk_state_1, onvalue=1, offvalue=0,
172 
173  command = CPU_exit_3).grid(row=3)
174 
175  b5 = tk.Checkbutton(text=cpu_b_txt,
176  fg = "black",
177  font = "Times 20 bold ",
178  variable=chk_state_1, onvalue=0, offvalue=1,
179 
180  command = CPU_exit_4).grid(row=4) # use same variable but inverted so they will track
181  b6 = tk.Button(text="CONFIRM",
182  fg = "blue",
183  font = "Times 20 bold ",
184  command = root_get_answer.destroy).grid(row=5, pady=4)
185 
186  b7 = tk.Button(text="CANCEL",
187  fg = "red",
188  font = "Times 12 bold ",
189  command = kill_session).grid(row=6, pady=4)
190 
191 
192  def CPU_exit_3_():
193  global get_answer_val
194  get_answer_val = 1
195 
196  def CPU_exit_4_():
197  global get_answer_val
198  get_answer_val = 2
199 
200  def kill_session_():
201  raise SystemExit(0) # kill everything
202 
203  root_get_answer.mainloop()
204 
205 # end - get answer
206 
207 
208 #
209 # move custom board definitions from project folder to PlatformIO
210 #
Here is the caller graph for this function:

◆ resolve_path()

def auto_build.resolve_path (   path)
211 def resolve_path(path):
212  import os
213 
214  # turn the selection into a partial path
215 
216  if 0 <= path.find('"'):
217  path = path[ path.find('"') : ]
218  if 0 <= path.find(', line '):
219  path = path.replace(', line ', ':')
220  path = path.replace('"', '')
221 
222  #get line and column numbers
223  line_num = 1
224  column_num = 1
225  line_start = path.find(':', 2) # use 2 here so don't eat Windows full path
226  column_start = path.find(':', line_start + 1)
227  if column_start == -1:
228  column_start = len(path)
229  column_end = path.find(':', column_start + 1)
230  if column_end == -1:
231  column_end = len(path)
232  if 0 <= line_start:
233  line_num = path[ line_start + 1 : column_start]
234  if line_num == '':
235  line_num = 1
236  if column_start != column_end:
237  column_num = path[ column_start + 1 : column_end]
238  if column_num == '':
239  column_num = 0
240 
241  index_end = path.find(',')
242  if 0 <= index_end:
243  path = path[ : index_end] # delete comma and anything after
244  index_end = path.find(':', 2)
245  if 0 <= index_end:
246  path = path[ : path.find(':', 2)] # delete the line number and anything after
247 
248  path = path.replace('\\','/')
249 
250  if 1 == path.find(':') and current_OS == 'Windows':
251  return path, line_num, column_num # found a full path - no need for further processing
252  elif 0 == path.find('/') and (current_OS == 'Linux' or current_OS == 'Darwin'):
253  return path, line_num, column_num # found a full path - no need for further processing
254 
255  else:
256 
257  # resolve as many '../' as we can
258  while 0 <= path.find('../'):
259  end = path.find('../') - 1
260  start = path.find('/')
261  while 0 <= path.find('/',start) and end > path.find('/',start):
262  start = path.find('/',start) + 1
263  path = path[0:start] + path[end + 4: ]
264 
265  # this is an alternative to the above - it just deletes the '../' section
266  # start_temp = path.find('../')
267  # while 0 <= path.find('../',start_temp):
268  # start = path.find('../',start_temp)
269  # start_temp = start + 1
270  # if 0 <= start:
271  # path = path[start + 2 : ]
272 
273 
274  start = path.find('/')
275  if start != 0: # make sure path starts with '/'
276  while 0 == path.find(' '): # eat any spaces at the beginning
277  path = path[ 1 : ]
278  path = '/' + path
279 
280  if current_OS == 'Windows':
281  search_path = path.replace('/', '\\') # os.walk uses '\' in Windows
282  else:
283  search_path = path
284 
285  start_path = os.path.abspath('')
286 
287  # search project directory for the selection
288  found = False
289  full_path = ''
290  for root, directories, filenames in os.walk(start_path):
291  for filename in filenames:
292  if 0 <= root.find('.git'): # don't bother looking in this directory
293  break
294  full_path = os.path.join(root,filename)
295  if 0 <= full_path.find(search_path):
296  found = True
297  break
298  if found:
299  break
300 
301  return full_path, line_num, column_num
302 
303 # end - resolve_path
304 
305 
306 #
307 # Opens the file in the preferred editor at the line & column number
308 # If the preferred editor isn't already running then it tries the next.
309 # If none are open then the system default is used.
310 #
311 # Editor order:
312 # 1. Notepad++ (Windows only)
313 # 2. Sublime Text
314 # 3. Atom
315 # 4. System default (opens at line 1, column 1 only)
316 #
Here is the caller graph for this function:

◆ open_file()

def auto_build.open_file (   path)
317 def open_file(path):
318  import subprocess
319  file_path, line_num, column_num = resolve_path(path)
320 
321  if file_path == '' :
322  return
323 
324  if current_OS == 'Windows':
325 
326  editor_note = subprocess.check_output('wmic process where "name=' + "'notepad++.exe'" + '" get ExecutablePath')
327  editor_sublime = subprocess.check_output('wmic process where "name=' + "'sublime_text.exe'" + '" get ExecutablePath')
328  editor_atom = subprocess.check_output('wmic process where "name=' + "'atom.exe'" + '" get ExecutablePath')
329 
330  if 0 <= editor_note.find('notepad++.exe'):
331  start = editor_note.find('\n') + 1
332  end = editor_note.find('\n',start + 5) -4
333  editor_note = editor_note[ start : end]
334  command = file_path , ' -n' + str(line_num) , ' -c' + str(column_num)
335  subprocess.Popen([editor_note, command])
336 
337  elif 0 <= editor_sublime.find('sublime_text.exe'):
338  start = editor_sublime.find('\n') + 1
339  end = editor_sublime.find('\n',start + 5) -4
340  editor_sublime = editor_sublime[ start : end]
341  command = file_path + ':' + line_num + ':' + column_num
342  subprocess.Popen([editor_sublime, command])
343 
344  elif 0 <= editor_atom.find('atom.exe'):
345  start = editor_atom.find('\n') + 1
346  end = editor_atom.find('\n',start + 5) -4
347  editor_atom = editor_atom[ start : end]
348  command = file_path + ':' + str(line_num) + ':' + str(column_num)
349  subprocess.Popen([editor_atom, command])
350 
351  else:
352  os.startfile(resolve_path(path)) # open file with default app
353 
354  elif current_OS == 'Linux':
355 
356  command = file_path + ':' + str(line_num) + ':' + str(column_num)
357  index_end = command.find(',')
358  if 0 <= index_end:
359  command = command[ : index_end] # sometimes a comma magically appears, don't want it
360  running_apps = subprocess.Popen('ps ax -o cmd', stdout=subprocess.PIPE, shell=True)
361  (output, err) = running_apps.communicate()
362  temp = output.split('\n')
363 
364  def find_editor_linux(name, search_obj):
365  for line in search_obj:
366  if 0 <= line.find(name):
367  path = line
368  return True, path
369  return False , ''
370 
371  (success_sublime, editor_path_sublime) = find_editor_linux('sublime_text',temp)
372  (success_atom, editor_path_atom) = find_editor_linux('atom',temp)
373 
374  if success_sublime:
375  subprocess.Popen([editor_path_sublime, command])
376 
377  elif success_atom:
378  subprocess.Popen([editor_path_atom, command])
379 
380  else:
381  os.system('xdg-open ' + file_path )
382 
383  elif current_OS == 'Darwin': # MAC
384 
385  command = file_path + ':' + str(line_num) + ':' + str(column_num)
386  index_end = command.find(',')
387  if 0 <= index_end:
388  command = command[ : index_end] # sometimes a comma magically appears, don't want it
389  running_apps = subprocess.Popen('ps axwww -o command', stdout=subprocess.PIPE, shell=True)
390  (output, err) = running_apps.communicate()
391  temp = output.split('\n')
392 
393  def find_editor_mac(name, search_obj):
394  for line in search_obj:
395  if 0 <= line.find(name):
396  path = line
397  if 0 <= path.find('-psn'):
398  path = path[ : path.find('-psn') - 1 ]
399  return True, path
400  return False , ''
401 
402  (success_sublime, editor_path_sublime) = find_editor_mac('Sublime',temp)
403  (success_atom, editor_path_atom) = find_editor_mac('Atom',temp)
404 
405  if success_sublime:
406  subprocess.Popen([editor_path_sublime, command])
407 
408  elif success_atom:
409  subprocess.Popen([editor_path_atom, command])
410 
411  else:
412  os.system('open ' + file_path )
413 # end - open_file
414 
415 
416 # gets the last build environment
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_build_last()

def auto_build.get_build_last ( )
417 def get_build_last():
418  env_last = ''
419  DIR_PWD = os.listdir('.')
420  if '.pio' in DIR_PWD:
421  date_last = 0.0
422  DIR__pioenvs = os.listdir('.pio')
423  for name in DIR__pioenvs:
424  if 0 <= name.find('.') or 0 <= name.find('-'): # skip files in listing
425  continue
426  DIR_temp = os.listdir('.pio/build/' + name)
427  for names_temp in DIR_temp:
428 
429  if 0 == names_temp.find('firmware.'):
430  date_temp = os.path.getmtime('.pio/build/' + name + '/' + names_temp)
431  if date_temp > date_last:
432  date_last = date_temp
433  env_last = name
434  return env_last
435 
436 
437 # gets the board being built from the Configuration.h file
438 # returns: board name, major version of Marlin being used (1 or 2)
Here is the caller graph for this function:

◆ get_board_name()

def auto_build.get_board_name ( )
439 def get_board_name():
440  board_name = ''
441  # get board name
442 
443  with open('Marlin/Configuration.h', 'r') as myfile:
444  Configuration_h = myfile.read()
445 
446  Configuration_h = Configuration_h.split('\n')
447  Marlin_ver = 0 # set version to invalid number
448  for lines in Configuration_h:
449  if 0 == lines.find('#define CONFIGURATION_H_VERSION 01'):
450  Marlin_ver = 1
451  if 0 == lines.find('#define CONFIGURATION_H_VERSION 02'):
452  Marlin_ver = 2
453  board = lines.find(' BOARD_') + 1
454  motherboard = lines.find(' MOTHERBOARD ') + 1
455  define = lines.find('#define ')
456  comment = lines.find('//')
457  if (comment == -1 or comment > board) and \
458  board > motherboard and \
459  motherboard > define and \
460  define >= 0 :
461  spaces = lines.find(' ', board) # find the end of the board substring
462  if spaces == -1:
463  board_name = lines[board : ]
464  else:
465  board_name = lines[board : spaces]
466  break
467 
468 
469  return board_name, Marlin_ver
470 
471 
472 # extract first environment name it finds after the start position
473 # returns: environment name and position to start the next search from
Here is the caller graph for this function:

◆ get_env_from_line()

def auto_build.get_env_from_line (   line,
  start_position 
)
474 def get_env_from_line(line, start_position):
475  env = ''
476  next_position = -1
477  env_position = line.find('env:', start_position)
478  if 0 < env_position:
479  next_position = line.find(' ', env_position + 4)
480  if 0 < next_position:
481  env = line[env_position + 4 : next_position]
482  else:
483  env = line[env_position + 4 : ] # at the end of the line
484  return env, next_position
485 
486 
487 
488 #scans pins.h for board name and returns the environment(s) it finds
Here is the caller graph for this function:

◆ get_starting_env()

def auto_build.get_starting_env (   board_name_full,
  version 
)
489 def get_starting_env(board_name_full, version):
490  # get environment starting point
491 
492  if version == 1:
493  path = 'Marlin/pins.h'
494  if version == 2:
495  path = 'Marlin/src/pins/pins.h'
496  with open(path, 'r') as myfile:
497  pins_h = myfile.read()
498 
499  env_A = ''
500  env_B = ''
501  env_C = ''
502 
503  board_name = board_name_full[ 6 : ] # only use the part after "BOARD_" since we're searching the pins.h file
504  pins_h = pins_h.split('\n')
505  environment = ''
506  board_line = ''
507  cpu_A = ''
508  cpu_B = ''
509  i = 0
510  list_start_found = False
511  for lines in pins_h:
512  i = i + 1 # i is always one ahead of the index into pins_h
513  if 0 < lines.find("Unknown MOTHERBOARD value set in Configuration.h"):
514  break # no more
515  if 0 < lines.find('1280'):
516  list_start_found = True
517  if list_start_found == False: # skip lines until find start of CPU list
518  continue
519  board = lines.find(board_name)
520  comment_start = lines.find('// ')
521  cpu_A_loc = comment_start
522  cpu_B_loc = 0
523  if board > 0: # need to look at the next line for environment info
524  cpu_line = pins_h[i]
525  comment_start = cpu_line.find('// ')
526  env_A, next_position = get_env_from_line(cpu_line, comment_start) # get name of environment & start of search for next
527  env_B, next_position = get_env_from_line(cpu_line, next_position) # get next environment, if it exists
528  env_C, next_position = get_env_from_line(cpu_line, next_position) # get next environment, if it exists
529  break
530  return env_A, env_B, env_C
531 
532 
533 # scans input string for CPUs that the users may need to select from
534 # returns: CPU name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_CPU_name()

def auto_build.get_CPU_name (   environment)
535 def get_CPU_name(environment):
536  CPU_list = ('1280', '2560','644', '1284', 'LPC1768', 'DUE')
537  CPU_name = ''
538  for CPU in CPU_list:
539  if 0 < environment.find(CPU):
540  return CPU
541 
542 
543 # get environment to be used for the build
544 # returns: environment
Here is the caller graph for this function:

◆ get_env()

def auto_build.get_env (   board_name,
  ver_Marlin 
)
545 def get_env(board_name, ver_Marlin):
546  def no_environment():
547  print('ERROR - no environment for this board')
548  print(board_name)
549  raise SystemExit(0) # no environment so quit
550 
551  def invalid_board():
552  print('ERROR - invalid board')
553  print(board_name)
554  raise SystemExit(0) # quit if unable to find board
555 
556 
557  CPU_question = ( ('1280', '2560', " 1280 or 2560 CPU? "), ('644', '1284', " 644 or 1284 CPU? ") )
558 
559  if 0 < board_name.find('MELZI') :
560  get_answer(' ' + board_name + ' ', " Which flavor of Melzi? ", "Melzi (Optiboot bootloader)", "Melzi ")
561  if 1 == get_answer_val:
562  target_env = 'melzi_optiboot'
563  else:
564  target_env = 'melzi'
565  else:
566  env_A, env_B, env_C = get_starting_env(board_name, ver_Marlin)
567 
568  if env_A == '':
569  no_environment()
570  if env_B == '':
571  return env_A # only one environment so finished
572 
573  CPU_A = get_CPU_name(env_A)
574  CPU_B = get_CPU_name(env_B)
575 
576  for item in CPU_question:
577  if CPU_A == item[0]:
578  get_answer(' ' + board_name + ' ', item[2], item[0], item[1])
579  if 2 == get_answer_val:
580  target_env = env_B
581  else:
582  target_env = env_A
583  return target_env
584 
585  if env_A == 'LPC1768':
586  if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'LPC1768_debug_and_upload'):
587  target_env = 'LPC1768_debug_and_upload'
588  else:
589  target_env = 'LPC1768'
590  elif env_A == 'DUE':
591  target_env = 'DUE'
592  if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'DUE_debug'):
593  target_env = 'DUE_debug'
594  elif env_B == 'DUE_USB':
595  get_answer(' ' + board_name + ' ', " DUE: need download port ", "USB (native USB) port", "Programming port ")
596  if 1 == get_answer_val:
597  target_env = 'DUE_USB'
598  else:
599  target_env = 'DUE'
600  else:
601  invalid_board()
602 
603  if build_type == 'traceback' and target_env != 'LPC1768_debug_and_upload' and target_env != 'DUE_debug' and Marlin_ver == 2:
604  print("ERROR - this board isn't setup for traceback")
605  print('board_name: ', board_name)
606  print('target_env: ', target_env)
607  raise SystemExit(0)
608 
609  return target_env
610 # end - get_env
611 
612 # puts screen text into queue so that the parent thread can fetch the data from this thread
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_to_screen_queue()

def auto_build.write_to_screen_queue (   text,
  format_tag = 'normal' 
)
619 def write_to_screen_queue(text, format_tag = 'normal'):
620  double_in = [text, format_tag]
621  IO_queue.put(double_in, block = False)
622 
623 
624 #
625 # send one line to the terminal screen with syntax highlighting
626 #
627 # input: unformatted text, flags from previous run
628 # returns: formatted text ready to go to the terminal, flags from this run
629 #
630 # This routine remembers the status from call to call because previous
631 # lines can affect how the current line is highlighted
632 #
633 
634 # 'static' variables - init here and then keep updating them from within print_line
Here is the caller graph for this function:

◆ line_print()

def auto_build.line_print (   line_input)
644 def line_print(line_input):
645 
646  global warning
647  global warning_FROM
648  global error
649  global standard
650  global prev_line_COM
651  global next_line_warning
652  global warning_continue
653  global line_counter
654 
655  # all '0' elements must precede all '1' elements or they'll be skipped
656  platformio_highlights = [
657  ['Environment', 0, 'highlight_blue'],
658  ['[SKIP]', 1, 'warning'],
659  ['[IGNORED]', 1, 'warning'],
660  ['[ERROR]', 1, 'error'],
661  ['[FAILED]', 1, 'error'],
662  ['[SUCCESS]', 1, 'highlight_green']
663  ]
664 
665  def write_to_screen_with_replace(text, highlights): # search for highlights & split line accordingly
666  did_something = False
667  for highlight in highlights:
668  found = text.find(highlight[0])
669  if did_something == True:
670  break
671  if found >= 0 :
672  did_something = True
673  if 0 == highlight[1]:
674  found_1 = text.find(' ')
675  found_tab = text.find('\t')
676  if found_1 < 0 or found_1 > found_tab:
677  found_1 = found_tab
678  write_to_screen_queue(text[ : found_1 + 1 ])
679  for highlight_2 in highlights:
680  if highlight[0] == highlight_2[0] :
681  continue
682  found = text.find(highlight_2[0])
683  if found >= 0 :
684  found_space = text.find(' ', found_1 + 1)
685  found_tab = text.find('\t', found_1 + 1)
686  if found_space < 0 or found_space > found_tab:
687  found_space = found_tab
688  found_right = text.find(']', found + 1)
689  write_to_screen_queue(text[found_1 + 1 : found_space + 1 ], highlight[2])
690  write_to_screen_queue(text[found_space + 1 : found + 1 ])
691  write_to_screen_queue(text[found + 1 : found_right], highlight_2[2])
692  write_to_screen_queue(text[found_right : ] + '\n')
693  break
694  break
695  if 1 == highlight[1]:
696  found_right = text.find(']', found + 1)
697  write_to_screen_queue(text[ : found + 1 ])
698  write_to_screen_queue(text[found + 1 : found_right ], highlight[2])
699  write_to_screen_queue(text[found_right : ] + '\n' + '\n')
700  break
701  if did_something == False:
702  r_loc = text.find('\r') + 1
703  if r_loc > 0 and r_loc < len(text): # need to split this line
704  text = text.split('\r')
705  for line in text:
706  if line != '':
707  write_to_screen_queue(line + '\n')
708  else:
709  write_to_screen_queue(text + '\n')
710  # end - write_to_screen_with_replace
711 
712 
713  # scan the line
714  line_counter = line_counter + 1
715  max_search = len(line_input)
716  if max_search > 3 :
717  max_search = 3
718  beginning = line_input[:max_search]
719 
720  # set flags
721  if 0 < line_input.find(': warning: '): # start of warning block
722  warning = True
723  warning_FROM = False
724  error = False
725  standard = False
726  prev_line_COM = False
727  prev_line_COM = False
728  warning_continue = True
729  if 0 < line_input.find('Thank you') or 0 < line_input.find('SUMMARY') :
730  warning = False #standard line found
731  warning_FROM = False
732  error = False
733  standard = True
734  prev_line_COM = False
735  warning_continue = False
736  elif beginning == 'War' or \
737  beginning == '#er' or \
738  beginning == 'In ' or \
739  (beginning != 'Com' and prev_line_COM == True and not(beginning == 'Arc' or beginning == 'Lin' or beginning == 'Ind') or \
740  next_line_warning == True):
741  warning = True #warning found
742  warning_FROM = False
743  error = False
744  standard = False
745  prev_line_COM = False
746  elif beginning == 'Com' or \
747  beginning == 'Ver' or \
748  beginning == ' [E' or \
749  beginning == 'Rem' or \
750  beginning == 'Bui' or \
751  beginning == 'Ind' or \
752  beginning == 'PLA':
753  warning = False #standard line found
754  warning_FROM = False
755  error = False
756  standard = True
757  prev_line_COM = False
758  warning_continue = False
759  elif beginning == '***':
760  warning = False # error found
761  warning_FROM = False
762  error = True
763  standard = False
764  prev_line_COM = False
765  elif 0 < line_input.find(': error:') or \
766  0 < line_input.find(': fatal error:'): # start of warning /error block
767  warning = False # error found
768  warning_FROM = False
769  error = True
770  standard = False
771  prev_line_COM = False
772  warning_continue = True
773  elif beginning == 'fro' and warning == True or \
774  beginning == '.pi' : # start of warning /error block
775  warning_FROM = True
776  prev_line_COM = False
777  warning_continue = True
778  elif warning_continue == True:
779  warning = True
780  warning_FROM = False # keep the warning status going until find a standard line or an error
781  error = False
782  standard = False
783  prev_line_COM = False
784  warning_continue = True
785 
786  else:
787  warning = False # unknown so assume standard line
788  warning_FROM = False
789  error = False
790  standard = True
791  prev_line_COM = False
792  warning_continue = False
793 
794  if beginning == 'Com':
795  prev_line_COM = True
796 
797  # print based on flags
798  if standard == True:
799  write_to_screen_with_replace(line_input, platformio_highlights) #print white on black with substitutions
800  if warning == True:
801  write_to_screen_queue(line_input + '\n', 'warning')
802  if error == True:
803  write_to_screen_queue(line_input + '\n', 'error')
804 # end - line_print
805 
806 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_PIO()

def auto_build.sys_PIO ( )
                                                                   #

run Platformio # #

824 def sys_PIO():
825 
826  ##########################################################################
827  # #
828  # run Platformio inside the same shell as this Python script #
829  # #
830  ##########################################################################
831 
832  global build_type
833  global target_env
834 
835  import os
836 
837  print('build_type: ', build_type)
838  print('starting platformio')
839 
840  if build_type == 'build':
841  # pio_result = os.system("echo -en '\033c'")
842  pio_result = os.system('platformio run -e ' + target_env)
843  elif build_type == 'clean':
844  pio_result = os.system('platformio run --target clean -e ' + target_env)
845  elif build_type == 'upload':
846  pio_result = os.system('platformio run --target upload -e ' + target_env)
847  elif build_type == 'traceback':
848  pio_result = os.system('platformio run --target upload -e ' + target_env)
849  elif build_type == 'program':
850  pio_result = os.system('platformio run --target program -e ' + target_env)
851  elif build_type == 'test':
852  pio_result = os.system('platformio test upload -e ' + target_env)
853  elif build_type == 'remote':
854  pio_result = os.system('platformio remote run --target program -e ' + target_env)
855  elif build_type == 'debug':
856  pio_result = os.system('platformio debug -e ' + target_env)
857  else:
858  print('ERROR - unknown build type: ', build_type)
859  raise SystemExit(0) # kill everything
860 
861  # stream output from subprocess and split it into lines
862  #for line in iter(pio_subprocess.stdout.readline, ''):
863  # line_print(line.replace('\n', ''))
864 
865 
866  # append info used to run PlatformIO
867  # write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen
868  # write_to_screen_queue('Build type: ' + build_type + '\n')
869  # write_to_screen_queue('Environment used: ' + target_env + '\n')
870  # write_to_screen_queue(str(datetime.now()) + '\n')
871 
872 # end - sys_PIO
873 
874 
875 
Here is the caller graph for this function:

◆ run_PIO()

def auto_build.run_PIO (   dummy)
876 def run_PIO(dummy):
877 
878  global build_type
879  global target_env
880  global board_name
881  print('build_type: ', build_type)
882 
883  import subprocess
884  import sys
885 
886  print('starting platformio')
887 
888  if build_type == 'build':
889  # platformio run -e target_env
890  # combine stdout & stderr so all compile messages are included
891  pio_subprocess = subprocess.Popen(['platformio', 'run', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
892 
893 
894  elif build_type == 'clean':
895  # platformio run --target clean -e target_env
896  # combine stdout & stderr so all compile messages are included
897  pio_subprocess = subprocess.Popen(['platformio', 'run', '--target', 'clean', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
898 
899 
900  elif build_type == 'upload':
901  # platformio run --target upload -e target_env
902  # combine stdout & stderr so all compile messages are included
903  pio_subprocess = subprocess.Popen(['platformio', 'run', '--target', 'upload', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
904 
905 
906  elif build_type == 'traceback':
907  # platformio run --target upload -e target_env - select the debug environment if there is one
908  # combine stdout & stderr so all compile messages are included
909  pio_subprocess = subprocess.Popen(['platformio', 'run', '--target', 'upload', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
910 
911 
912  elif build_type == 'program':
913  # platformio run --target program -e target_env
914  # combine stdout & stderr so all compile messages are included
915  pio_subprocess = subprocess.Popen(['platformio', 'run', '--target', 'program', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
916 
917 
918  elif build_type == 'test':
919  #platformio test upload -e target_env
920  # combine stdout & stderr so all compile messages are included
921  pio_subprocess = subprocess.Popen(['platformio', 'test', 'upload', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
922 
923 
924  elif build_type == 'remote':
925  # platformio remote run --target upload -e target_env
926  # combine stdout & stderr so all compile messages are included
927  pio_subprocess = subprocess.Popen(['platformio', 'remote', 'run', '--target', 'program', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
928 
929 
930  elif build_type == 'debug':
931  # platformio debug -e target_env
932  # combine stdout & stderr so all compile messages are included
933  pio_subprocess = subprocess.Popen(['platformio', 'debug', '-e', target_env], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
934 
935 
936  else:
937  print('ERROR - unknown build type: ', build_type)
938  raise SystemExit(0) # kill everything
939 
940  # stream output from subprocess and split it into lines
941  if python_ver == 2:
942  for line in iter(pio_subprocess.stdout.readline, ''):
943  line_print(line.replace('\n', ''))
944  else:
945  for line in iter(pio_subprocess.stdout.readline, b''):
946  line = line.decode('utf-8')
947  line_print(line.replace('\n', ''))
948 
949  # append info used to run PlatformIO
950  write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen
951  write_to_screen_queue('Build type: ' + build_type + '\n')
952  write_to_screen_queue('Environment used: ' + target_env + '\n')
953  write_to_screen_queue(str(datetime.now()) + '\n')
954 
955 # end - run_PIO
956 
957 
958 
Here is the call graph for this function:

◆ main()

def auto_build.main ( void  )
1270 def main():
1271 
1272 
1273  ##########################################################################
1274  # #
1275  # main program #
1276  # #
1277  ##########################################################################
1278 
1279  global build_type
1280  global target_env
1281  global board_name
1282 
1283  board_name, Marlin_ver = get_board_name()
1284 
1285  target_env = get_env(board_name, Marlin_ver)
1286 
1287  # Re-use the VSCode terminal, if possible
1288  if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode':
1289  sys_PIO()
1290  else:
1291  auto_build = output_window()
1292  auto_build.start_thread() # executes the "run_PIO" function
1293 
1294  auto_build.root.mainloop()
1295 
1296 
1297 
Here is the call graph for this function:

Variable Documentation

◆ pwd

auto_build.pwd = os.getcwd()

◆ num_args

auto_build.num_args = len(sys.argv)

◆ build_type

auto_build.build_type = str(sys.argv[1])

◆ python_ver

auto_build.python_ver = sys.version_info[0]

◆ current_OS

auto_build.current_OS = platform.system()

◆ target_env

string auto_build.target_env = ''

◆ board_name

string auto_build.board_name = ''

◆ IO_queue

auto_build.IO_queue = queue.Queue()

◆ warning

bool auto_build.warning = False

◆ warning_FROM

bool auto_build.warning_FROM = False

◆ error

bool auto_build.error = False

◆ standard

bool auto_build.standard = True

◆ prev_line_COM

bool auto_build.prev_line_COM = False

◆ next_line_warning

bool auto_build.next_line_warning = False

◆ warning_continue

bool auto_build.warning_continue = False

◆ line_counter

int auto_build.line_counter = 0

◆ que

auto_build.que = queue.Queue()
auto_build.get_build_last
def get_build_last()
Definition: auto_build.py:417
auto_build.get_board_name
def get_board_name()
Definition: auto_build.py:439
auto_build.resolve_path
def resolve_path(path)
Definition: auto_build.py:211
auto_build.line_print
def line_print(line_input)
Definition: auto_build.py:644
auto_build.open_file
def open_file(path)
Definition: auto_build.py:317
auto_build.get_CPU_name
def get_CPU_name(environment)
Definition: auto_build.py:535
auto_build.get_env_from_line
def get_env_from_line(line, start_position)
Definition: auto_build.py:474
auto_build.get_env
def get_env(board_name, ver_Marlin)
Definition: auto_build.py:545
auto_build.sys_PIO
def sys_PIO()
Definition: auto_build.py:824
main
int main(void)
The application entry point.
Definition: main.c:161
auto_build.write_to_screen_queue
def write_to_screen_queue(text, format_tag='normal')
Definition: auto_build.py:619
auto_build.run_PIO
def run_PIO(dummy)
Definition: auto_build.py:876
auto_build.get_answer
def get_answer(board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt)
Python 2 error messages: Can't find a usable init.tcl in the following directories ....
Definition: auto_build.py:129
auto_build.get_starting_env
def get_starting_env(board_name_full, version)
Definition: auto_build.py:489