コード例 #1
0
 def _generate_lines(self, session_name, env_exports):
     lines = list()
     lines.append("# RC file generated on %s" % (date.rcf8222date()))
     lines.append("")
     if env_exports:
         lines.append(
             "# Environment settings (these will need to be exported)")
         for (k, v) in env_exports.items():
             lines.append("# export %s=%s" % (k, sh.shellquote(v)))
         lines.append("")
     if ROOT_GO:
         lines.append(
             "# Screen sockets & programs were created/ran as the root user"
         )
         lines.append(
             "# So you will need to run as user root (or sudo) to enter the following sessions"
         )
         lines.append("")
     lines.append("# Session settings")
     lines.append("sessionname %s" % (session_name))
     lines.append(STATUS_BAR_CMD)
     lines.append("screen -t %s bash" % (SESSION_DEF_TITLE))
     lines.append("")
     lines.extend(self._generate_help(session_name, env_exports))
     return lines
コード例 #2
0
 def _get_upstart_conf_params(self, app_pth, program_name, *program_args):
     params = dict()
     if self.cfg.getboolean('upstart', 'respawn'):
         params['RESPAWN'] = "respawn"
     else:
         params['RESPAWN'] = ""
     params['SHORT_NAME'] = program_name
     params['MADE_DATE'] = date.rcf8222date()
     params['START_EVENT'] = self.cfg.getdefaulted('upstart', 'start_event',
                                                   'all_os_start')
     params['STOP_EVENT'] = self.cfg.getdefaulted('upstart', 'stop_event',
                                                  'all_os_stop')
     params[
         'COMPONENT_START_EVENT'] = self.component_name + START_EVENT_SUFFIX
     params[
         'COMPONENT_STOP_EVENT'] = self.component_name + STOP_EVENT_SUFFIX
     params['PROGRAM_NAME'] = app_pth
     params['AUTHOR'] = settings.PROG_NICE_NAME
     if program_args:
         escaped_args = list()
         for opt in program_args:
             LOG.debug("Current opt: %s" % (opt))
             escaped_args.append(sh.shellquote(opt))
         params['PROGRAM_OPTIONS'] = " ".join(escaped_args)
     else:
         params['PROGRAM_OPTIONS'] = ''
     return params
コード例 #3
0
 def _generate_help(self, session_name, env_exports):
     lines = list()
     lines.append("# Screen help stuff")
     cmd_pieces = list()
     for (k, v) in env_exports.items():
         cmd_pieces.append("%s=%s" % (k, sh.shellquote(v)))
     cmd_pieces.append("screen -r %s" % (session_name))
     if ROOT_GO:
         cmd_pieces.insert(0, "sudo")
     lines.append("# To connect to this session run the following command: ")
     lines.append("# %s" % (" ".join(cmd_pieces)))
     lines.append("")
     return lines
コード例 #4
0
 def _generate_help(self, session_name, env_exports):
     lines = list()
     lines.append("# Screen help stuff")
     cmd_pieces = list()
     for (k, v) in env_exports.items():
         cmd_pieces.append("%s=%s" % (k, sh.shellquote(v)))
     cmd_pieces.append("screen -r %s" % (session_name))
     if ROOT_GO:
         cmd_pieces.insert(0, "sudo")
     lines.append(
         "# To connect to this session run the following command: ")
     lines.append("# %s" % (" ".join(cmd_pieces)))
     lines.append("")
     return lines
コード例 #5
0
 def _generate_lines(self, session_name, env_exports):
     lines = list()
     lines.append("# RC file generated on %s" % (date.rcf8222date()))
     lines.append("")
     if env_exports:
         lines.append("# Environment settings (these will need to be exported)")
         for (k, v) in env_exports.items():
             lines.append("# export %s=%s" % (k, sh.shellquote(v)))
         lines.append("")
     if ROOT_GO:
         lines.append("# Screen sockets & programs were created/ran as the root user")
         lines.append("# So you will need to run as user root (or sudo) to enter the following sessions")
         lines.append("")
     lines.append("# Session settings")
     lines.append("sessionname %s" % (session_name))
     lines.append(STATUS_BAR_CMD)
     lines.append("screen -t %s bash" % (SESSION_DEF_TITLE))
     lines.append("")
     lines.extend(self._generate_help(session_name, env_exports))
     return lines
コード例 #6
0
 def _get_upstart_conf_params(self, app_pth, program_name, *program_args):
     params = dict()
     if self.cfg.getboolean('upstart', 'respawn'):
         params['RESPAWN'] = "respawn"
     else:
         params['RESPAWN'] = ""
     params['SHORT_NAME'] = program_name
     params['MADE_DATE'] = date.rcf8222date()
     params['START_EVENT'] = self.cfg.get('upstart', 'start_event')
     params['STOP_EVENT'] = self.cfg.get('upstart', 'stop_event')
     params['COMPONENT_START_EVENT'] = self.component_name + START_EVENT_SUFFIX
     params['COMPONENT_STOP_EVENT'] = self.component_name + STOP_EVENT_SUFFIX
     params['PROGRAM_NAME'] = app_pth
     params['AUTHOR'] = settings.PROG_NICE_NAME
     if program_args:
         escaped_args = list()
         for opt in program_args:
             LOG.debug("Current opt: %s" % (opt))
             escaped_args.append(sh.shellquote(opt))
         params['PROGRAM_OPTIONS'] = " ".join(escaped_args)
     else:
         params['PROGRAM_OPTIONS'] = ''
     return params
コード例 #7
0
 def _make_export(self, export_name, value):
     escaped_val = sh.shellquote(value)
     full_line = "export %s=%s" % (export_name, escaped_val)
     return full_line
コード例 #8
0
 def _make_export(self, export_name, value):
     escaped_val = sh.shellquote(value)
     full_line = "export %s=%s" % (export_name, escaped_val)
     return full_line