update_res.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys
  2. import awtk_locator as locator
  3. LONGSOPTS = ['awtk_root=', 'AWTK_ROOT=']
  4. def get_args(args, longsopts = []) :
  5. list_opts = []
  6. for arg in args:
  7. if arg.startswith('--') :
  8. tmp_opt = '';
  9. for opt in longsopts:
  10. if arg.find(opt) > 0 :
  11. tmp_opt = opt;
  12. break
  13. if tmp_opt != '' :
  14. list_opts.append(arg.split(tmp_opt)[1])
  15. continue
  16. else :
  17. print(arg + " not find command, command :")
  18. print(longsopts)
  19. sys.exit()
  20. return list_opts
  21. def update_res(ARGUMENTS, is_new_usage):
  22. locator.init(ARGUMENTS)
  23. import update_res_app as updater
  24. if is_new_usage and not hasattr(updater, "getopt") :
  25. print(" must update awtk !!!")
  26. sys.exit()
  27. updater.run(locator.getAwtkRoot())
  28. is_new_usage = False
  29. opts = get_args(sys.argv[1:], LONGSOPTS)
  30. ARGUMENTS = dict()
  31. if len(opts) > 0 :
  32. is_new_usage = True
  33. ARGUMENTS['AWTK_ROOT'] = opts[0]
  34. else :
  35. ARGUMENTS['AWTK_ROOT'] = ''
  36. update_res(ARGUMENTS, is_new_usage)