コード例 #1
0
ファイル: ui_node.py プロジェクト: mydaisy2/targetcli
 def ui_command_exit(self):
     '''
     Exits the command line interface.
     '''
     if getuid() == 0:
         config = Config()
         if isfile(STARTUP_CONFIG):
             config.load(STARTUP_CONFIG, allow_new_attrs=True)
         saved_config = config.dump()
         config.load_live()
         live_config = config.dump()
         if saved_config != live_config:
             self.shell.con.display("There are unsaved configuration changes.\n"
                                    "If you exit now, configuration will not "
                                    "be updated and changes will be lost upon "
                                    "reboot.")
             try:
                 input = raw_input("Type 'exit' if you want to exit anyway: ")
             except EOFError:
                 input = None
                 self.shell.con.display('')
             if input == "exit":
                 return 'EXIT'
             else:
                 self.shell.log.warning("Aborted exit, use 'saveconfig' to "
                                        "save the current configuration.")
         else:
             return 'EXIT'
     else:
         return 'EXIT'
コード例 #2
0
ファイル: ui_node.py プロジェクト: wedged/targetcli
 def ui_command_exit(self):
     '''
     Exits the command line interface.
     '''
     if getuid() == 0:
         self.shell.log.info("Comparing startup and running configs...")
         try:
             config = Config()
             if isfile(STARTUP_CONFIG):
                 config.load(STARTUP_CONFIG, allow_new_attrs=True)
             saved_config = config.dump()
             config.load_live()
             live_config = config.dump()
             if saved_config != live_config:
                 self.shell.log.info("Some changes need saving.")
                 self.ui_command_saveconfig()
             else:
                 self.shell.log.info("Startup config is up-to-date.")
         except Exception, e:
             self.shell.log.warning(e)
コード例 #3
0
ファイル: ui_node.py プロジェクト: dresong/targetcli
 def ui_command_exit(self):
     '''
     Exits the command line interface.
     '''
     if getuid() == 0:
         self.shell.log.info("Comparing startup and running configs...")
         try:
             config = Config()
             if isfile(STARTUP_CONFIG):
                 config.load(STARTUP_CONFIG, allow_new_attrs=True)
             saved_config = config.dump()
             config.load_live()
             live_config = config.dump()
             if saved_config != live_config:
                 self.shell.log.info("Some changes need saving.")
                 self.ui_command_saveconfig()
             else:
                 self.shell.log.info("Startup config is up-to-date.")
         except Exception, e:
             self.shell.log.warning(e)