Ejemplo n.º 1
0
Archivo: Init.py Proyecto: ab/bcfg2
    def _prompt_certificate(self):
        """Ask for the key details (country, state, and location)."""
        print("The following questions affect SSL certificate generation.")
        print("If no data is provided, the default values are used.")
        newcountry = input("Country name (2 letter code) for certificate: ")
        if newcountry != '':
            if len(newcountry) == 2:
                self.country = newcountry
            else:
                while len(newcountry) != 2:
                    newcountry = input("2 letter country code (eg. US): ")
                    if len(newcountry) == 2:
                        self.country = newcountry
                        break
        else:
            self.country = 'US'

        newstate = input("State or Province Name (full name) for certificate: ")
        if newstate != '':
            self.state = newstate
        else:
            self.state = 'Illinois'

        newlocation = input("Locality Name (eg, city) for certificate: ")
        if newlocation != '':
            self.location = newlocation
        else:
            self.location = 'Argonne'
Ejemplo n.º 2
0
    def _prompt_certificate(self):
        """Ask for the key details (country, state, and location)."""
        print("The following questions affect SSL certificate generation.")
        print("If no data is provided, the default values are used.")
        newcountry = input("Country name (2 letter code) for certificate: ")
        if newcountry != '':
            if len(newcountry) == 2:
                self.data['country'] = newcountry
            else:
                while len(newcountry) != 2:
                    newcountry = input("2 letter country code (eg. US): ")
                    if len(newcountry) == 2:
                        self.data['country'] = newcountry
                        break
        else:
            self.data['country'] = 'US'

        newstate = input("State or Province Name (full name) for "
                         "certificate: ")
        if newstate != '':
            self.data['state'] = newstate
        else:
            self.data['state'] = 'Illinois'

        newlocation = input("Locality Name (eg, city) for certificate: ")
        if newlocation != '':
            self.data['location'] = newlocation
        else:
            self.data['location'] = 'Argonne'
Ejemplo n.º 3
0
 def _prompt_keypath(self):
     """ Ask for the key pair location.  Try to use sensible
     defaults depending on the OS """
     keypath = input("Path where Bcfg2 server private key will be created "
                     "[%s]: " % self.data['keypath'])
     if keypath:
         self.data['keypath'] = keypath
     certpath = input("Path where Bcfg2 server cert will be created"
                      "[%s]: " % self.data['certpath'])
     if certpath:
         self.data['certpath'] = certpath
Ejemplo n.º 4
0
Archivo: Init.py Proyecto: timl/bcfg2
 def _prompt_keypath(self):
     """ Ask for the key pair location.  Try to use sensible
     defaults depending on the OS """
     keypath = input("Path where Bcfg2 server private key will be created "
                     "[%s]: " % self.data['keypath'])
     if keypath:
         self.data['keypath'] = keypath
     certpath = input("Path where Bcfg2 server cert will be created"
                      "[%s]: " % self.data['certpath'])
     if certpath:
         self.data['certpath'] = certpath
Ejemplo n.º 5
0
Archivo: Init.py Proyecto: ab/bcfg2
 def _prompt_repopath(self):
     """Ask for the repository path."""
     while True:
         newrepo = input("Location of Bcfg2 repository [%s]: " %
                         self.repopath)
         if newrepo != '':
             self.repopath = os.path.abspath(newrepo)
         if os.path.isdir(self.repopath):
             response = input("Directory %s exists. Overwrite? [y/N]:" \
                              % self.repopath)
             if response.lower().strip() == 'y':
                 break
         else:
             break
Ejemplo n.º 6
0
 def _prompt_repopath(self):
     """Ask for the repository path."""
     while True:
         newrepo = input("Location of Bcfg2 repository [%s]: " %
                         self.data['repopath'])
         if newrepo != '':
             self.data['repopath'] = os.path.abspath(newrepo)
         if os.path.isdir(self.data['repopath']):
             response = input("Directory %s exists. Overwrite? [y/N]:" %
                              self.data['repopath'])
             if response.lower().strip() == 'y':
                 break
         else:
             break
Ejemplo n.º 7
0
Archivo: Init.py Proyecto: ab/bcfg2
 def _prompt_plugins(self):
     default = input("Use default plugins? (%s) [Y/n]: " %
                     ''.join(default_plugins)).lower()
     if default != 'y' or default != '':
         while True:
             plugins_are_valid = True
             plug_str = input("Specify plugins: ")
             plugins = plug_str.split(',')
             for plugin in plugins:
                 plugin = plugin.strip()
                 if not plugin in plugin_list:
                     plugins_are_valid = False
                     print("ERROR: Plugin %s not recognized" % plugin)
             if plugins_are_valid:
                 break
Ejemplo n.º 8
0
 def _prompt_hostname(self):
     """Ask for the server hostname."""
     data = input("What is the server's hostname [%s]: " % socket.getfqdn())
     if data != '':
         self.data['shostname'] = data
     else:
         self.data['shostname'] = socket.getfqdn()
Ejemplo n.º 9
0
Archivo: Action.py Proyecto: ab/bcfg2
 def RunAction(self, entry):
     """This method handles command execution and status return."""
     if not self.setup['dryrun']:
         if self.setup['interactive']:
             prompt = ('Run Action %s, %s: (y/N): ' %
                       (entry.get('name'), entry.get('command')))
             ans = input(prompt)
             if ans not in ['y', 'Y']:
                 return False
         if self.setup['servicemode'] == 'build':
             if entry.get('build', 'true') == 'false':
                 self.logger.debug("Action: Deferring execution of %s due to build mode" % (entry.get('command')))
                 return False
         self.logger.debug("Running Action %s" % (entry.get('name')))
         rc = self.cmd.run(entry.get('command'))[0]
         self.logger.debug("Action: %s got rc %s" % (entry.get('command'), rc))
         entry.set('rc', str(rc))
         if entry.get('status', 'check') == 'ignore':
             return True
         else:
             return rc == 0
     else:
         self.logger.debug("In dryrun mode: not running action: %s" %
                           (entry.get('name')))
         return False
Ejemplo n.º 10
0
 def RunAction(self, entry):
     """This method handles command execution and status return."""
     if not self.setup['dryrun']:
         if self.setup['interactive']:
             prompt = ('Run Action %s, %s: (y/N): ' %
                       (entry.get('name'), entry.get('command')))
             ans = input(prompt)
             if ans not in ['y', 'Y']:
                 return False
         if self.setup['servicemode'] == 'build':
             if entry.get('build', 'true') == 'false':
                 self.logger.debug("Action: Deferring execution of %s due "
                                   "to build mode" % entry.get('command'))
                 return False
         self.logger.debug("Running Action %s" % (entry.get('name')))
         rv = self.cmd.run(entry.get('command'))[0]
         self.logger.debug("Action: %s got return code %s" %
                           (entry.get('command'), rv))
         entry.set('rc', str(rv))
         if entry.get('status', 'check') == 'ignore':
             return True
         else:
             return rv == 0
     else:
         self.logger.debug("In dryrun mode: not running action: %s" %
                           (entry.get('name')))
         return False
Ejemplo n.º 11
0
    def Choose(self, choices):
        """Determine where to put pull data."""
        if self.mode == 'interactive':
            for choice in choices:
                print("Plugin returned choice:")
                if id(choice) == id(choices[0]):
                    print("(current entry) ")
                if choice.all:
                    print(" => global entry")
                elif choice.group:
                    print(" => group entry: %s (prio %d)" %
                          (choice.group, choice.prio))
                else:
                    print(" => host entry: %s" % (choice.hostname))

                # flush input buffer
                while len(select.select([sys.stdin.fileno()], [], [],
                                        0.0)[0]) > 0:
                    os.read(sys.stdin.fileno(), 4096)
                ans = input("Use this entry? [yN]: ") in ['y', 'Y']
                if ans:
                    return choice
            return False
        else:
            # mode == 'force'
            if not choices:
                return False
            return choices[0]
Ejemplo n.º 12
0
    def BundleUpdated(self, bundle, states):
        """The Bundle has been updated."""
        if self.setup['servicemode'] == 'disabled':
            return

        for entry in [ent for ent in bundle if self.handlesEntry(ent)]:
            restart = entry.get("restart", "true")
            if (restart.lower() == "false"
                    or (restart.lower == "interactive"
                        and not self.setup['interactive'])):
                continue

            rv = None
            if entry.get('status') == 'on':
                if self.setup['servicemode'] == 'build':
                    rv = self.stop_service(entry)
                elif entry.get('name') not in self.restarted:
                    if self.setup['interactive']:
                        prompt = ('Restart service %s?: (y/N): ' %
                                  entry.get('name'))
                        ans = input(prompt)
                        if ans not in ['y', 'Y']:
                            continue
                    rv = self.restart_service(entry)
                    if not rv:
                        self.restarted.append(entry.get('name'))
            else:
                rv = self.stop_service(entry)
            if rv:
                self.logger.error("Failed to manipulate service %s" %
                                  (entry.get('name')))
Ejemplo n.º 13
0
Archivo: __init__.py Proyecto: ab/bcfg2
    def BundleUpdated(self, bundle, states):
        """The Bundle has been updated."""
        if self.setup['servicemode'] == 'disabled':
            return

        for entry in [ent for ent in bundle if self.handlesEntry(ent)]:
            restart = entry.get("restart", "true")
            if (restart.lower() == "false" or
                (restart.lower == "interactive" and
                 not self.setup['interactive'])):
                continue

            rc = None
            if entry.get('status') == 'on':
                if self.setup['servicemode'] == 'build':
                    rc = self.stop_service(entry)
                elif entry.get('name') not in self.restarted:
                    if self.setup['interactive']:
                        prompt = ('Restart service %s?: (y/N): ' %
                                  entry.get('name'))
                        ans = input(prompt)
                        if ans not in ['y', 'Y']:
                            continue
                    rc = self.restart_service(entry)
                    if not rc:
                        self.restarted.append(entry.get('name'))
            else:
                rc = self.stop_service(entry)
            if rc:
                self.logger.error("Failed to manipulate service %s" %
                                  (entry.get('name')))
Ejemplo n.º 14
0
Archivo: Pull.py Proyecto: rcuza/bcfg2
    def Choose(self, choices):
        """Determine where to put pull data."""
        if self.mode == 'interactive':
            for choice in choices:
                print("Plugin returned choice:")
                if id(choice) == id(choices[0]):
                    print("(current entry) ")
                if choice.all:
                    print(" => global entry")
                elif choice.group:
                    print(" => group entry: %s (prio %d)" %
                          (choice.group, choice.prio))
                else:
                    print(" => host entry: %s" % (choice.hostname))

                # flush input buffer
                while len(select.select([sys.stdin.fileno()], [], [],
                                        0.0)[0]) > 0:
                    os.read(sys.stdin.fileno(), 4096)
                ans = input("Use this entry? [yN]: ") in ['y', 'Y']
                if ans:
                    return choice
            return False
        else:
            # mode == 'force'
            if not choices:
                return False
            return choices[0]
Ejemplo n.º 15
0
 def promptFilter(self, prompt, entries):
     """Filter a supplied list based on user input."""
     ret = []
     entries.sort(cmpent)
     for entry in entries[:]:
         if entry in self.unhandled:
             # don't prompt for entries that can't be installed
             continue
         if 'qtext' in entry.attrib:
             iprompt = entry.get('qtext')
         else:
             iprompt = prompt % (entry.tag, entry.get('name'))
         # flush input buffer
         while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
             os.read(sys.stdin.fileno(), 4096)
         try:
             ans = input(iprompt.encode(sys.stdout.encoding, 'replace'))
             if ans in ['y', 'Y']:
                 ret.append(entry)
         except EOFError:
             # python 2.4.3 on CentOS doesn't like ^C for some reason
             break
         except:
             print("Error while reading input")
             continue
     return ret
Ejemplo n.º 16
0
 def RunAction(self, entry):
     """This method handles command execution and status return."""
     if not self.setup['dryrun']:
         if self.setup['interactive']:
             prompt = ('Run Action %s, %s: (y/N): ' %
                       (entry.get('name'), entry.get('command')))
             # flush input buffer
             while len(select.select([sys.stdin.fileno()], [], [],
                                     0.0)[0]) > 0:
                 os.read(sys.stdin.fileno(), 4096)
             ans = input(prompt)
             if ans not in ['y', 'Y']:
                 return False
         if self.setup['servicemode'] == 'build':
             if entry.get('build', 'true') == 'false':
                 self.logger.debug("Action: Deferring execution of %s due "
                                   "to build mode" % entry.get('command'))
                 return False
         self.logger.debug("Running Action %s" % (entry.get('name')))
         rv = self.cmd.run(entry.get('command'))
         self.logger.debug("Action: %s got return code %s" %
                           (entry.get('command'), rv.retval))
         entry.set('rc', str(rv.retval))
         return entry.get('status', 'check') == 'ignore' or rv.success
     else:
         self.logger.debug("In dryrun mode: not running action: %s" %
                           (entry.get('name')))
         return False
Ejemplo n.º 17
0
    def BundleUpdated(self, bundle, states):
        if self.setup['servicemode'] == 'disabled':
            return

        for entry in [ent for ent in bundle if self.handlesEntry(ent)]:
            restart = entry.get("restart", "true")
            if (restart.lower() == "false" or
                (restart.lower() == "interactive" and
                 not self.setup['interactive'])):
                continue

            rv = None
            if entry.get('status') == 'on':
                if self.setup['servicemode'] == 'build':
                    rv = self.stop_service(entry)
                elif entry.get('name') not in self.restarted:
                    if self.setup['interactive']:
                        prompt = ('Restart service %s?: (y/N): ' %
                                  entry.get('name'))
                        # flush input buffer
                        while len(select.select([sys.stdin.fileno()], [], [],
                                                0.0)[0]) > 0:
                            os.read(sys.stdin.fileno(), 4096)
                        ans = input(prompt)
                        if ans not in ['y', 'Y']:
                            continue
                    rv = self.restart_service(entry)
                    if not rv:
                        self.restarted.append(entry.get('name'))
            else:
                rv = self.stop_service(entry)
            if rv:
                self.logger.error("Failed to manipulate service %s" %
                                  (entry.get('name')))
Ejemplo n.º 18
0
 def RunAction(self, entry):
     """This method handles command execution and status return."""
     if not self.setup['dryrun']:
         if self.setup['interactive']:
             prompt = ('Run Action %s, %s: (y/N): ' %
                       (entry.get('name'), entry.get('command')))
             # flush input buffer
             while len(select.select([sys.stdin.fileno()], [], [],
                                     0.0)[0]) > 0:
                 os.read(sys.stdin.fileno(), 4096)
             ans = input(prompt)
             if ans not in ['y', 'Y']:
                 return False
         if self.setup['servicemode'] == 'build':
             if entry.get('build', 'true') == 'false':
                 self.logger.debug("Action: Deferring execution of %s due "
                                   "to build mode" % entry.get('command'))
                 return False
         self.logger.debug("Running Action %s" % (entry.get('name')))
         rv = self.cmd.run(entry.get('command'))
         self.logger.debug("Action: %s got return code %s" %
                           (entry.get('command'), rv.retval))
         entry.set('rc', str(rv.retval))
         return entry.get('status', 'check') == 'ignore' or rv.success
     else:
         self.logger.debug("In dryrun mode: not running action: %s" %
                           (entry.get('name')))
         return False
Ejemplo n.º 19
0
Archivo: Init.py Proyecto: ab/bcfg2
 def _prompt_hostname(self):
     """Ask for the server hostname."""
     data = input("What is the server's hostname [%s]: " %
                  socket.getfqdn())
     if data != '':
         self.shostname = data
     else:
         self.shostname = socket.getfqdn()
Ejemplo n.º 20
0
def prompt(msg):
    """ Helper to give a yes/no prompt to the user.  Flushes input
    buffers, handles exceptions, etc.  Returns True if the user
    answers in the affirmative, False otherwise.

    :param msg: The message to show to the user.  The message is not
                altered in any way for display; i.e., it should
                contain "[y/N]" if desired, etc.
    :type msg: string
    :returns: bool - True if yes, False if no """
    while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
        os.read(sys.stdin.fileno(), 4096)
    try:
        ans = input(msg)
        return ans in ['y', 'Y']
    except UnicodeEncodeError:
        ans = input(msg.encode('utf-8'))
        return ans in ['y', 'Y']
    except EOFError:
        # handle ^C on rhel-based platforms
        raise SystemExit(1)
Ejemplo n.º 21
0
 def _prompt_groups(self):
     """Create the groups.xml file."""
     prompt = '''Input base Operating System for clients:\n'''
     for entry in OS_LIST:
         prompt += "%d: %s\n" % (OS_LIST.index(entry) + 1, entry[0])
     prompt += ': '
     while True:
         try:
             osidx = int(input(prompt))
             self.data['os_sel'] = OS_LIST[osidx - 1][1]
             break
         except ValueError:
             continue
Ejemplo n.º 22
0
Archivo: Init.py Proyecto: ab/bcfg2
 def _prompt_groups(self):
     """Create the groups.xml file."""
     prompt = '''Input base Operating System for clients:\n'''
     for entry in os_list:
         prompt += "%d: %s\n" % (os_list.index(entry) + 1, entry[0])
     prompt += ': '
     while True:
         try:
             osidx = int(input(prompt))
             self.os_sel = os_list[osidx - 1][1]
             break
         except ValueError:
             continue
Ejemplo n.º 23
0
def create_conf(confpath, confdata):
    """ create the config file """
    # Don't overwrite existing bcfg2.conf file
    if os.path.exists(confpath):
        result = input("\nWarning: %s already exists. "
                       "Overwrite? [y/N]: " % confpath)
        if result not in ['Y', 'y']:
            print("Leaving %s unchanged" % confpath)
            return
    try:
        open(confpath, "w").write(confdata)
        os.chmod(confpath, stat.S_IRUSR | stat.S_IWUSR)  # 0600
    except Exception:
        err = sys.exc_info()[1]
        print("Error trying to write configuration file '%s': %s" %
              (confpath, err))
        raise SystemExit(1)
Ejemplo n.º 24
0
 def __call__(self, args):
     Bcfg2.Server.Admin.Mode.__call__(self, args)
     badfiles = self.buildTidyList()
     if '-f' in args or '-I' in args:
         if '-I' in args:
             for name in badfiles[:]:
                 answer = input("Unlink file %s? [yN] " % name)
                 if answer not in ['y', 'Y']:
                     badfiles.remove(name)
         for name in badfiles:
             try:
                 os.unlink(name)
             except IOError:
                 print("Failed to unlink %s" % name)
     else:
         for name in badfiles:
             print(name)
Ejemplo n.º 25
0
Archivo: Init.py Proyecto: ab/bcfg2
def create_conf(confpath, confdata, keypath):
    # Don't overwrite existing bcfg2.conf file
    if os.path.exists(confpath):
        result = input("\nWarning: %s already exists. "
                       "Overwrite? [y/N]: " % confpath)
        if result not in ['Y', 'y']:
            print("Leaving %s unchanged" % confpath)
            return
    try:
        open(confpath, "w").write(confdata)
        os.chmod(confpath, stat.S_IRUSR | stat.S_IWUSR)  # 0600
    except Exception:
        e = sys.exc_info()[1]
        print("Error %s occured while trying to write configuration "
              "file to '%s'.\n" %
               (e, confpath))
        raise SystemExit(1)
Ejemplo n.º 26
0
def prompt(msg):
    """ Helper to give a yes/no prompt to the user.  Flushes input
    buffers, handles exceptions, etc.  Returns True if the user
    answers in the affirmative, False otherwise.

    :param msg: The message to show to the user.  The message is not
                altered in any way for display; i.e., it should
                contain "[y/N]" if desired, etc.
    :type msg: string
    :returns: bool - True if yes, False if no """
    while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
        os.read(sys.stdin.fileno(), 4096)
    try:
        ans = input(msg)
        return ans in ['y', 'Y']
    except EOFError:
        # handle ^C on rhel-based platforms
        raise SystemExit(1)
Ejemplo n.º 27
0
def prompt(msg):
    """ Helper to give a yes/no prompt to the user.  Flushes input
    buffers, handles exceptions, etc.  Returns True if the user
    answers in the affirmative, False otherwise.

    :param msg: The message to show to the user.  The message is not
                altered in any way for display; i.e., it should
                contain "[y/N]" if desired, etc.
    :type msg: string
    :returns: bool - True if yes, False if no """
    while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
        os.read(sys.stdin.fileno(), 4096)
    try:
        ans = input(msg.encode(sys.stdout.encoding, 'replace'))
        return ans in ['y', 'Y']
    except EOFError:
        # python 2.4.3 on CentOS doesn't like ^C for some reason
        return False
    except:
        print("Error while reading input: %s" % sys.exc_info()[1])
        return False
Ejemplo n.º 28
0
def prompt(msg):
    """ Helper to give a yes/no prompt to the user.  Flushes input
    buffers, handles exceptions, etc.  Returns True if the user
    answers in the affirmative, False otherwise.

    :param msg: The message to show to the user.  The message is not
                altered in any way for display; i.e., it should
                contain "[y/N]" if desired, etc.
    :type msg: string
    :returns: bool - True if yes, False if no """
    while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
        os.read(sys.stdin.fileno(), 4096)
    try:
        ans = input(msg)
        return ans in ['y', 'Y']
    except EOFError:
        # python 2.4.3 on CentOS doesn't like ^C for some reason
        return False
    except:
        print("Error while reading input: %s" % sys.exc_info()[1])
        return False
Ejemplo n.º 29
0
 def promptFilter(self, prompt, entries):
     """Filter a supplied list based on user input."""
     ret = []
     entries.sort(cmpent)
     for entry in entries[:]:
         if entry in self.unhandled:
             # don't prompt for entries that can't be installed
             continue
         if 'qtext' in entry.attrib:
             iprompt = entry.get('qtext')
         else:
             iprompt = prompt % (entry.tag, entry.get('name'))
         try:
             ans = input(iprompt.encode(sys.stdout.encoding, 'replace'))
             if ans in ['y', 'Y']:
                 ret.append(entry)
         except EOFError:
             # python 2.4.3 on CentOS doesn't like ^C for some reason
             break
         except:
             print("Error while reading input")
             continue
     return ret
Ejemplo n.º 30
0
    def Choose(self, choices):
        """Determine where to put pull data."""
        if self.mode == 'interactive':
            for choice in choices:
                print("Plugin returned choice:")
                if id(choice) == id(choices[0]):
                    print("(current entry) ")
                if choice.all:
                    print(" => global entry")
                elif choice.group:
                    print(" => group entry: %s (prio %d)" %
                          (choice.group, choice.prio))
                else:
                    print(" => host entry: %s" % (choice.hostname))

                ans = input("Use this entry? [yN]: ") in ['y', 'Y']
                if ans:
                    return choice
            return False
        else:
            # mode == 'force'
            if not choices:
                return False
            return choices[0]
Ejemplo n.º 31
0
Archivo: Pull.py Proyecto: timl/bcfg2
    def Choose(self, choices):
        """Determine where to put pull data."""
        if self.mode == 'interactive':
            for choice in choices:
                print("Plugin returned choice:")
                if id(choice) == id(choices[0]):
                    print("(current entry) ")
                if choice.all:
                    print(" => global entry")
                elif choice.group:
                    print(" => group entry: %s (prio %d)" %
                          (choice.group, choice.prio))
                else:
                    print(" => host entry: %s" % (choice.hostname))

                ans = input("Use this entry? [yN]: ") in ['y', 'Y']
                if ans:
                    return choice
            return False
        else:
            # mode == 'force'
            if not choices:
                return False
            return choices[0]
Ejemplo n.º 32
0
def safe_input(prompt):
    """ input() that flushes the input buffer before accepting input """
    # flush input buffer
    while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
        os.read(sys.stdin.fileno(), 4096)
    return input(prompt)
Ejemplo n.º 33
0
 def _prompt_config(self):
     """Ask for the configuration file path."""
     newconfig = input("Store Bcfg2 configuration in [%s]: " %
                       self.configfile)
     if newconfig != '':
         self.data['configfile'] = os.path.abspath(newconfig)
Ejemplo n.º 34
0
Archivo: Init.py Proyecto: ab/bcfg2
 def _prompt_server(self):
     """Ask for the server name."""
     newserver = input("Input the server location [%s]: " %
                       self.server_uri)
     if newserver != '':
         self.server_uri = newserver
Ejemplo n.º 35
0
 def _prompt_server(self):
     """Ask for the server name."""
     newserver = input("Input the server location [%s]: " %
                       self.data['server_uri'])
     if newserver != '':
         self.data['server_uri'] = newserver
Ejemplo n.º 36
0
Archivo: Init.py Proyecto: ab/bcfg2
 def _prompt_config(self):
     """Ask for the configuration file path."""
     newconfig = input("Store Bcfg2 configuration in [%s]: " %
                       self.configfile)
     if newconfig != '':
         self.configfile = os.path.abspath(newconfig)
Ejemplo n.º 37
0
def safe_input(msg):
    """ input() that flushes the input buffer before accepting input """
    # flush input buffer
    while len(select.select([sys.stdin.fileno()], [], [], 0.0)[0]) > 0:
        os.read(sys.stdin.fileno(), 4096)
    return input(msg)