本文整理汇总了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
示例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)
示例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
示例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)
示例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
示例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
示例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)
示例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)
示例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()