示例#1
0
 def do_option(self, event=None):
     curr_option = self.__options[0][self.__index]
     print('Doing option {}'.format(curr_option))
     if opath.isdir(opath.join(self.__pp_dir, curr_option)):
         print('It is a directory')
         self.__mod_prefix.append(opath.splitext(opath.basename(curr_option))[0])
         self.__dirs, self.__commands = loader.find_ppmodules(curr_option)
         if self.__is_root_dir:
             self.__commands.append('Exit')
             self.__is_root_dir = False
         else:
             self.__commands.append('Back')
         self.__options.appendleft(self.make_options(self.__dirs, self.__commands))
         self.__index = -1
         self.__title.appendleft(self.__mod_prefix[-1])
         self.next_option()
     elif curr_option == 'Exit':
         print('It is the exit command')
         exit_barrier.wait()
     elif curr_option == 'Back':
         print('It is the back command')
         print('Popping options')
         self.__options.popleft()
         print('New options:')
         for opt in self.__options[0]:
             print('\tOption {}'.format(opt))
         print('Popping mod_prefix')
         self.__mod_prefix.pop()
         print('New mod_prefix: {}'.format(self.__mod_prefix.__str__()))
         self.__index = -1
         self.__title.popleft()
         self.next_option()
     else:
         print('It is a module to run')
         self.__mod_prefix.append(opath.splitext(opath.basename(curr_option))[0])
         pkg_name = '.'.join(self.__mod_prefix)
         print('{} is a package'.format(pkg_name))
         mod_name = self.__mod_prefix[-1]
         print('{} is the module'.format(mod_name))
         mod = __import__(pkg_name, fromlist=[self.__mod_prefix[:-1]])
         mod.run(cad=self.__cad)
         self.__mod_prefix.pop()
         print('Done running module')
示例#2
0
 def start(self):
     """Entry point for the platypi system
     Return: Status (0 or 1)
     """
     #self.set_title(self.__title)
     print('Getting modules')
     self.__dirs, self.__commands = loader.find_ppmodules(opath.join(self.__pp_dir, PPMOD_DIR))
     #self.__commands.append(self.__exit_mod)
     self.__commands.append('Exit')
     self.__is_root_dir = False
     self.__options.appendleft(self.make_options(self.__dirs,
                                                 self.__commands))
      # DEBUG
     print('Current options:')
     for opt in self.__options[0]:
         print('\tOption {}'.format(opt))
     # END DEBUG
     self.__index = len(self.__options[0]) - 1
     self.next_option()