Python-ELMO is a Python library which offers an encapsulation of the binary tool ELMO, in order to manipulate it easily in Python and SageMath script.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

  1. import sys
  2. from .utils import Color
  3. if len(sys.argv) <= 1:
  4. print(Color.FAIL + 'Please enter an instruction.' + Color.ENDC)
  5. exit()
  6. command = sys.argv[1]
  7. if command == 'create-simulation':
  8. import os, shutil
  9. import re
  10. print('Creation of a new simulation project...')
  11. ### Create the repository of the projects
  12. global_path = 'projects'
  13. os.makedirs(global_path, exist_ok=True)
  14. ### Get the project classname
  15. project_classname = ''
  16. search = re.compile(r'[^a-zA-Z0-9_]').search
  17. while not project_classname:
  18. classname = input(' - What is the project classname? ')
  19. if search(classname):
  20. print(' > Illegal characters detected! Please enter a name with only the following characters : a-z, A-Z, 0-9, and "_".')
  21. else:
  22. project_classname = classname.strip()
  23. ### Get and create the project repository
  24. search = re.compile(r'[^a-zA-Z0-9.-_/]').search
  25. project_repository = ''
  26. while not project_repository:
  27. repository = input(' - What is the project repository? ')
  28. if search(repository):
  29. print('Illegal characters detected! Please enter a name with only the following characters : a-z, A-Z, 0-9, ".", "-", "_" and "/".')
  30. else:
  31. project_repository = repository
  32. project_path = global_path+'/'+repository
  33. from .manage import create_simulation
  34. project_path = create_simulation(project_path, classname)
  35. print('')
  36. print('Creation complete !')
  37. print(' - Project repository: {}'.format(project_path))
  38. print(' - Project class "{}" in {}'.format(project_classname, project_path+'/projectclass.py'))
  39. print(' - Linker script: {}'.format(project_path+'/project.ld'))
  40. print('')
  41. print('Please don\'t to compile the project with the present Makefile before using it!')
  42. exit()
  43. if command == 'run-server':
  44. from .executor import launch_executor
  45. from .config import DEFAULT_HOST, DEFAULT_PORT
  46. host = sys.argv[2] if len(sys.argv) >= 3 else DEFAULT_HOST
  47. port = int(sys.argv[3]) if len(sys.argv) >= 4 else DEFAULT_PORT
  48. launch_executor(host, port)
  49. exit()
  50. print(Color.FAIL + 'Unknown Command.' + Color.ENDC)
  51. exit()