當前位置: 首頁>>代碼示例>>Python>>正文


Python builtins.input方法代碼示例

本文整理匯總了Python中future.builtins.input方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.input方法的具體用法?Python builtins.input怎麽用?Python builtins.input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在future.builtins的用法示例。


在下文中一共展示了builtins.input方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_folders

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def check_folders(name):
    """Only checks and asks questions. Nothing is written to disk."""

    if os.getcwd().endswith('analyses'):
        correct = input('You are in an analyses folder. This will create '
                        'another analyses folder inside this one. Do '
                        'you want to continue? (y/N)')
        if correct != 'y':
            return False

    if not os.path.exists(os.path.join(os.getcwd(), 'analyses')):
        correct = input('This is the first analysis here. Do '
                        'you want to continue? (y/N)')
        if correct != 'y':
            return False

    if os.path.exists(os.path.join(os.getcwd(), 'analyses', name)):
        correct = input('An analysis with this name exists already. Do '
                        'you want to continue? (y/N)')
        if correct != 'y':
            return False

    return True 
開發者ID:svenkreiss,項目名稱:databench,代碼行數:25,代碼來源:scaffold.py

示例2: start_crawler

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def start_crawler(self, index, daemonize=False):
        """
        Starts a crawler from the input-array.

        :param int index: The array-index of the site
        :param int daemonize: Bool if the crawler is supposed to be daemonized
                              (to delete the JOBDIR)
        """
        call_process = [sys.executable,
                        self.__single_crawler,
                        self.cfg_file_path,
                        self.json_file_path,
                        "%s" % index,
                        "%s" % self.shall_resume,
                        "%s" % daemonize]

        self.log.debug("Calling Process: %s", call_process)

        crawler = Popen(call_process,
                        stderr=None,
                        stdout=None)
        crawler.communicate()
        self.crawlers.append(crawler) 
開發者ID:fhamborg,項目名稱:news-please,代碼行數:25,代碼來源:__main__.py

示例3: prompt_user_passwd

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def prompt_user_passwd(self, host, realm):
        """Override this in a GUI environment!"""
        import getpass
        try:
            user = input("Enter username for %s at %s: " % (realm, host))
            passwd = getpass.getpass("Enter password for %s in %s at %s: " %
                (user, realm, host))
            return user, passwd
        except KeyboardInterrupt:
            print()
            return None, None


# Utility functions 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:16,代碼來源:request.py

示例4: getInput

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def getInput(self, _message):
        global firstTime
        global runningScript
        global runningImport
        if runningScript == True:
            if firstTime == False:
                self.message = input('\n\tWrite message to be analyzed: ')
                _message = self.message
                self.countPunct(_message)
                self.countWordSent(_message)
                self.runAnalysis(_message)
            else: 
                print("""\n\tNow starting Emote as a script. Use Emote Mass Analyzer to break down a text into individual sentence 
                 classifications, or import Emote as a library.""")
                print("\n\tThe first time you run the analysis will be a little bit slower.")
                firstTime = False
                self.initialTrain()
        else:
            if firstTime == True:
                # print("\nFIRST TIME IS TRUE")
                print("\n\tRunning Emote as a library..")
                self.message = _message
                runningImport = True
                self.countPunct(_message)
                self.countWordSent(_message)
                self.runAnalysis(_message)
            else:
                # print("\nFIRST TIME IS FALSE")
                runningImport = True
                self.message = _message
                self.countPunct(_message)
                self.countWordSent(_message)
                self.runAnalysis(_message) 
開發者ID:jddunn,項目名稱:emoter,代碼行數:35,代碼來源:emote.py

示例5: deploy

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def deploy():
    """
    Deploy latest version of the project.
    Check out the latest version of the project from version
    control, install new requirements, sync and migrate the database,
    collect any new static assets, and restart gunicorn's work
    processes for the project.
    """
    if not exists(env.venv_path):
        prompt = input("\nVirtualenv doesn't exist: %s"
                       "\nWould you like to create it? (yes/no) "
                       % env.proj_name)
        if prompt.lower() != "yes":
            print("\nAborting!")
            return False
        create()
    for name in get_templates():
        upload_template_and_reload(name)
    with project():
        backup("last.db")
        static_dir = static()
        if exists(static_dir):
            run("tar -cf last.tar %s" % static_dir)
        git = env.git
        last_commit = "git rev-parse HEAD" if git else "hg id -i"
        run("%s > last.commit" % last_commit)
        with update_changed_requirements():
            run("git pull origin master -f" if git else "hg pull && hg up -C")
        manage("collectstatic -v 0 --noinput")
        manage("syncdb --noinput")
        manage("migrate --noinput")
    restart()
    return True 
開發者ID:keithadavidson,項目名稱:ansible-mezzanine,代碼行數:35,代碼來源:fabfile.py

示例6: init_config_file_path_if_empty

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def init_config_file_path_if_empty(self):
        """
        if the config file path does not exist, this function will initialize the path with a default
        config file
        :return
        """

        if os.path.exists(self.cfg_directory_path):
            return

        user_choice = 'n'
        if self.no_confirm:
            user_choice = 'y'
        else:
            sys.stdout.write(
                "Config directory does not exist at '" + os.path.abspath(self.cfg_directory_path) + "'. "
                + "Should a default configuration be created at this path? [Y/n] ")
            if sys.version_info[0] < 3:
                user_choice = raw_input()
            else:
                user_choice = input()
            user_choice = user_choice.lower().replace("yes", "y").replace("no", "n")

        if not user_choice or user_choice == '':  # the default is yes
            user_choice = "y"
        if "y" not in user_choice and "n" not in user_choice:
            sys.stderr.write("Wrong input, aborting.")
            sys.exit(1)
        if "n" in user_choice:
            sys.stdout.write("Config file will not be created. Terminating.")
            sys.exit(1)

        # copy the default config file to the new path
        copy_tree(os.environ['CColon'] + os.path.sep + 'config', self.cfg_directory_path)
        return 
開發者ID:fhamborg,項目名稱:news-please,代碼行數:37,代碼來源:__main__.py

示例7: reset_mysql

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def reset_mysql(self):
        """
        Resets the MySQL database.
        """

        confirm = self.no_confirm

        print("""
Cleanup MySQL database:
    This will truncate all tables and reset the whole database.
""")

        if not confirm:
            confirm = 'yes' in builtins.input(
                """
    Do you really want to do this? Write 'yes' to confirm: {yes}"""
                    .format(yes='yes' if confirm else ''))

        if not confirm:
            print("Did not type yes. Thus aborting.")
            return

        print("Resetting database...")

        try:
            # initialize DB connection
            self.conn = pymysql.connect(host=self.mysql["host"],
                                        port=self.mysql["port"],
                                        db=self.mysql["db"],
                                        user=self.mysql["username"],
                                        passwd=self.mysql["password"])
            self.cursor = self.conn.cursor()

            self.cursor.execute("TRUNCATE TABLE CurrentVersions")
            self.cursor.execute("TRUNCATE TABLE ArchiveVersions")
            self.conn.close()
        except (pymysql.err.OperationalError, pymysql.ProgrammingError, pymysql.InternalError,
                pymysql.IntegrityError, TypeError) as error:
            self.log.error("Database reset error: %s", error) 
開發者ID:fhamborg,項目名稱:news-please,代碼行數:41,代碼來源:__main__.py

示例8: reset_elasticsearch

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def reset_elasticsearch(self):
        """
        Resets the Elasticsearch Database.
        """

        print("""
Cleanup Elasticsearch database:
    This will truncate all tables and reset the whole Elasticsearch database.
              """)

        confirm = self.no_confirm

        if not confirm:
            confirm = 'yes' in builtins.input(
                """
Do you really want to do this? Write 'yes' to confirm: {yes}"""
                    .format(yes='yes' if confirm else ''))

        if not confirm:
            print("Did not type yes. Thus aborting.")
            return

        try:
            # initialize DB connection
            es = Elasticsearch([self.elasticsearch["host"]],
                               http_auth=(self.elasticsearch["username"], self.elasticsearch["secret"]),
                               port=self.elasticsearch["port"],
                               use_ssl=self.elasticsearch["use_ca_certificates"],
                               verify_certs=self.elasticsearch["use_ca_certificates"],
                               ca_certs=self.elasticsearch["ca_cert_path"],
                               client_cert=self.elasticsearch["client_cert_path"],
                               client_key=self.elasticsearch["client_key_path"])

            print("Resetting Elasticsearch database...")
            es.indices.delete(index=self.elasticsearch["index_current"], ignore=[400, 404])
            es.indices.delete(index=self.elasticsearch["index_archive"], ignore=[400, 404])
        except ConnectionError as error:
            self.log.error("Failed to connect to Elasticsearch. "
                           "Please check if the database is running and the config is correct: %s" % error) 
開發者ID:fhamborg,項目名稱:news-please,代碼行數:41,代碼來源:__main__.py

示例9: reset_postgresql

# 需要導入模塊: from future import builtins [as 別名]
# 或者: from future.builtins import input [as 別名]
def reset_postgresql(self):
        """
        Resets the Postgresql database.
        """

        confirm = self.no_confirm

        print("""
Cleanup Postgresql database:
    This will truncate all tables and reset the whole database.
""")

        if not confirm:
            confirm = 'yes' in builtins.input(
                """
    Do you really want to do this? Write 'yes' to confirm: {yes}"""
                    .format(yes='yes' if confirm else ''))

        if not confirm:
            print("Did not type yes. Thus aborting.")
            return

        print("Resetting database...")

        try:
            # initialize DB connection
            self.conn = psycopg2.connect(host=self.postgresql["host"],
                                        port=self.postgresql["port"],
                                        database=self.postgresql["database"],
                                        user=self.postgresql["user"],
                                        password=self.postgresql["password"])
            self.cursor = self.conn.cursor()

            self.cursor.execute("TRUNCATE TABLE CurrentVersions RESTART IDENTITY")
            self.cursor.execute("TRUNCATE TABLE ArchiveVersions RESTART IDENTITY")
            self.conn.commit()
            self.cursor.close()

        except psycopg2.DatabaseError as error:
            self.log.error("Database reset error: %s", error)
        finally:
            if self.conn is not None:
                self.conn.close() 
開發者ID:fhamborg,項目名稱:news-please,代碼行數:45,代碼來源:__main__.py


注:本文中的future.builtins.input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。