本文整理汇总了Python中txclib.log.logger.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getset_host_credentials
def getset_host_credentials(self, host, user=None, password=None):
"""
Read .transifexrc and report user,pass for a specific host else ask the
user for input.
"""
try:
username = self.txrc.get(host, 'username')
passwd = self.txrc.get(host, 'password')
except (configparser.NoOptionError, configparser.NoSectionError):
logger.info("No entry found for host %s. Creating..." % host)
username = user or input("Please enter your transifex username: ")
while (not username):
username = input("Please enter your transifex username: ")
passwd = password
while (not passwd):
passwd = getpass.getpass()
logger.info("Updating %s file..." % self.txrc_file)
self.txrc.add_section(host)
self.txrc.set(host, 'username', username)
self.txrc.set(host, 'password', passwd)
self.txrc.set(host, 'token', '')
self.txrc.set(host, 'hostname', host)
return username, passwd
开发者ID:akx,项目名称:transifex-client,代码行数:25,代码来源:project.py
示例2: cmd_pull
def cmd_pull(argv, path_to_tx):
"Pull files from remote server to local repository"
parser = pull_parser()
(options, args) = parser.parse_args(argv)
if options.fetchall and options.languages:
parser.error("You can't user a language filter along with the"\
" -a|--all option")
languages = parse_csv_option(options.languages)
resources = parse_csv_option(options.resources)
pseudo = options.pseudo
skip = options.skip_errors
minimum_perc = options.minimum_perc or None
try:
_go_to_dir(path_to_tx)
except UnInitializedError as e:
utils.logger.error(e)
return
# instantiate the project.Project
prj = project.Project(path_to_tx)
prj.pull(
languages=languages, resources=resources, overwrite=options.overwrite,
fetchall=options.fetchall, fetchsource=options.fetchsource,
force=options.force, skip=skip, minimum_perc=minimum_perc,
mode=options.mode, pseudo=pseudo
)
logger.info("Done.")
开发者ID:akx,项目名称:transifex-client,代码行数:28,代码来源:commands.py
示例3: cmd_pull
def cmd_pull(argv, path_to_tx):
"""Pull files from remote server to local repository"""
parser = pull_parser()
options = parser.parse_args(argv)
if options.fetchall and options.languages:
parser.error("You can't user a language filter along with the "
"-a|--all option")
languages = parse_csv_option(options.languages)
resources = parse_csv_option(options.resources)
pseudo = options.pseudo
# Should we download as xliff?
xliff = options.xliff
parallel = options.parallel
skip = options.skip_errors
minimum_perc = options.minimum_perc or None
_go_to_dir(path_to_tx)
# instantiate the project.Project
prj = project.Project(path_to_tx)
branch = get_branch_from_options(options, prj.root)
prj.pull(
languages=languages, resources=resources, overwrite=options.overwrite,
fetchall=options.fetchall, fetchsource=options.fetchsource,
force=options.force, skip=skip, minimum_perc=minimum_perc,
mode=options.mode, pseudo=pseudo, xliff=xliff, branch=branch,
parallel=parallel, no_interactive=options.no_interactive,
)
logger.info("Done.")
开发者ID:transifex,项目名称:transifex-client,代码行数:29,代码来源:commands.py
示例4: cmd_status
def cmd_status(argv, path_to_tx):
"Print status of current project"
parser = status_parser()
(options, args) = parser.parse_args(argv)
resources = parse_csv_option(options.resources)
prj = project.Project(path_to_tx)
resources = prj.get_chosen_resources(resources)
resources_num = len(resources)
for idx, res in enumerate(resources):
p, r = res.split('.')
logger.info("%s -> %s (%s of %s)" % (p, r, idx + 1, resources_num))
logger.info("Translation Files:")
slang = prj.get_resource_option(res, 'source_lang')
sfile = prj.get_resource_option(res, 'source_file') or "N/A"
lang_map = prj.get_resource_lang_mapping(res)
logger.info(" - %s: %s (%s)" % (utils.color_text(slang, "RED"),
sfile, utils.color_text("source", "YELLOW")))
files = prj.get_resource_files(res)
fkeys = files.keys()
fkeys.sort()
for lang in fkeys:
local_lang = lang
if lang in lang_map.values():
local_lang = lang_map.flip[lang]
logger.info(" - %s: %s" % (utils.color_text(local_lang, "RED"),
files[lang]))
logger.info("")
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:27,代码来源:commands.py
示例5: _delete_translations
def _delete_translations(self, project_details,
resource, stats, languages):
"""Delete the specified translations for the specified resource."""
logger.info("Deleting translations from resource %s:" % resource)
for language in languages:
self._delete_translation(
project_details, resource, stats, language
)
开发者ID:masaori335,项目名称:transifex-client,代码行数:8,代码来源:project.py
示例6: cmd_init
def cmd_init(argv, path_to_tx):
"Initialize a new transifex project."
parser = init_parser()
(options, args) = parser.parse_args(argv)
if len(args) > 1:
parser.error("Too many arguments were provided. Aborting...")
if args:
path_to_tx = args[0]
else:
path_to_tx = os.getcwd()
if os.path.isdir(os.path.join(path_to_tx,".tx")):
logger.info("tx: There is already a tx folder!")
reinit = raw_input("Do you want to delete it and reinit the project? [y/N]: ")
while (reinit != 'y' and reinit != 'Y' and reinit != 'N' and reinit != 'n' and reinit != ''):
reinit = raw_input("Do you want to delete it and reinit the project? [y/N]: ")
if not reinit or reinit in ['N', 'n', 'NO', 'no', 'No']:
return
# Clean the old settings
# FIXME: take a backup
else:
rm_dir = os.path.join(path_to_tx, ".tx")
shutil.rmtree(rm_dir)
logger.info("Creating .tx folder...")
os.mkdir(os.path.join(path_to_tx,".tx"))
# Handle the credentials through transifexrc
home = os.path.expanduser("~")
txrc = os.path.join(home, ".transifexrc")
config = OrderedRawConfigParser()
default_transifex = "https://www.transifex.net"
transifex_host = options.host or raw_input("Transifex instance [%s]: " % default_transifex)
if not transifex_host:
transifex_host = default_transifex
if not transifex_host.startswith(('http://', 'https://')):
transifex_host = 'https://' + transifex_host
config_file = os.path.join(path_to_tx, ".tx", "config")
if not os.path.exists(config_file):
# The path to the config file (.tx/config)
logger.info("Creating skeleton...")
config = OrderedRawConfigParser()
config.add_section('main')
config.set('main', 'host', transifex_host)
# Touch the file if it doesn't exist
logger.info("Creating config file...")
fh = open(config_file, 'w')
config.write(fh)
fh.close()
prj = project.Project(path_to_tx)
prj.getset_host_credentials(transifex_host, user=options.user,
password=options.password)
prj.save()
logger.info("Done.")
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:58,代码来源:commands.py
示例7: modify_expr
def modify_expr():
"""Modify the file filter of a resource."""
prj = project.Project(path_to_tx)
res_id = request.form['res_id']
expr = request.form['value']
logger.info("Changing expression of %s to %s" % (res_id, expr))
prj.config.set("%s" % res_id, "file_filter", expr)
prj.save()
return expr
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:9,代码来源:commands.py
示例8: pull
def pull():
resourceLink = request.form["resources"]
resources = resourceLink.split("*//")
prj = project.Project(path_to_tx)
#resource = request.args.get('resource')
logger.info(resources[-1])
#prj.pull(resources=[resource], fetchall=True, skip=True)
return jsonify(result="OK")
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:9,代码来源:wui.py
示例9: push
def push():
resourceLink = request.form["resources"]
resources = resourceLink.split("*//")
logger.info("zaab")
prj = project.Project(path_to_tx)
try:
prj.push(resources=resources, source=True)
prj.push(resources=resources, skip=True, translations=True, source=False)
return "success"
except:
return "failed"
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:11,代码来源:wui.py
示例10: cmd_delete
def cmd_delete(argv, path_to_tx):
"Delete an accessible resource or translation in a remote server."
parser = delete_parser()
(options, args) = parser.parse_args(argv)
languages = parse_csv_option(options.languages)
resources = parse_csv_option(options.resources)
skip = options.skip_errors
force = options.force_delete
prj = project.Project(path_to_tx)
prj.delete(resources, languages, skip, force)
logger.info("Done.")
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:11,代码来源:commands.py
示例11: cmd_init
def cmd_init(argv, path_to_tx):
"""Initialize a new Transifex project."""
parser = init_parser()
options = parser.parse_args(argv)
path_to_tx = options.path_to_tx or os.getcwd()
print(messages.init_intro)
save = options.save
# if we already have a config file and we are not told to override it
# in the args we have to ask
config_file = os.path.join(path_to_tx, ".tx", "config")
if os.path.isfile(config_file):
if not save:
if options.no_interactive:
parser.error("Project already initialized.")
logger.info(messages.init_initialized)
if not utils.confirm(messages.init_reinit):
return
os.remove(config_file)
if not os.path.isdir(os.path.join(path_to_tx, ".tx")):
logger.info("Creating .tx folder...")
os.mkdir(os.path.join(path_to_tx, ".tx"))
default_transifex = "https://www.transifex.com"
transifex_host = options.host or default_transifex
if not transifex_host.startswith(('http://', 'https://')):
transifex_host = 'https://' + transifex_host
if not os.path.exists(config_file):
# Handle the credentials through transifexrc
config = OrderedRawConfigParser()
config.add_section('main')
config.set('main', 'host', transifex_host)
# Touch the file if it doesn't exist
logger.info("Creating config file...")
fh = open(config_file, 'w')
config.write(fh)
fh.close()
if not options.skipsetup and not options.no_interactive:
logger.info(messages.running_tx_set)
cmd_config([], path_to_tx)
else:
prj = project.Project(path_to_tx)
prj.getset_host_credentials(transifex_host, username=options.user,
password=options.password,
token=options.token, force=options.save,
no_interactive=options.no_interactive)
prj.save()
logger.info("Done.")
开发者ID:transifex,项目名称:transifex-client,代码行数:52,代码来源:commands.py
示例12: _set_source_file
def _set_source_file(path_to_tx, resource, lang, path_to_file):
"""Reusable method to set source file."""
proj, res = resource.split('.')
if not proj or not res:
raise Exception("\"%s.%s\" is not a valid resource identifier. "
"It should be in the following format "
"project_slug.resource_slug." %
(proj, res))
if not lang:
raise Exception("You haven't specified a source language.")
try:
_go_to_dir(path_to_tx)
except UnInitializedError as e:
utils.logger.error(e)
return
if not os.path.exists(path_to_file):
raise Exception("tx: File ( %s ) does not exist." %
os.path.join(path_to_tx, path_to_file))
# instantiate the project.Project
prj = project.Project(path_to_tx)
root_dir = os.path.abspath(path_to_tx)
if root_dir not in os.path.normpath(os.path.abspath(path_to_file)):
raise Exception("File must be under the project root directory.")
logger.info("Setting source file for resource %s.%s ( %s -> %s )." % (
proj, res, lang, path_to_file))
path_to_file = os.path.relpath(path_to_file, root_dir)
prj = project.Project(path_to_tx)
# FIXME: Check also if the path to source file already exists.
try:
try:
prj.config.get("%s.%s" % (proj, res), "source_file")
except configparser.NoSectionError:
prj.config.add_section("%s.%s" % (proj, res))
except configparser.NoOptionError:
pass
finally:
prj.config.set(
"%s.%s" % (proj, res), "source_file", posix_path(path_to_file)
)
prj.config.set("%s.%s" % (proj, res), "source_lang", lang)
prj.save()
开发者ID:TASERAxon,项目名称:transifex-client,代码行数:50,代码来源:commands.py
示例13: cmd_help
def cmd_help(argv, path_to_tx):
"""List all available commands"""
parser = help_parser()
(options, args) = parser.parse_args(argv)
if len(args) > 1:
parser.error("Multiple arguments received. Exiting...")
# Get all commands
fns = utils.discover_commands()
# Print help for specific command
if len(args) == 1:
try:
fns[argv[0]](['--help'], path_to_tx)
except KeyError:
utils.logger.error("Command %s not found" % argv[0])
# or print summary of all commands
# the code below will only be executed if the KeyError exception is thrown
# becuase in all other cases the function called with --help will exit
# instead of return here
keys = fns.keys()
keys.sort()
logger.info("Transifex command line client.\n")
logger.info("Available commands are:")
for key in keys:
logger.info(" %-15s\t%s" % (key, fns[key].func_doc))
logger.info("\nFor more information run %s command --help" % sys.argv[0])
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:29,代码来源:commands.py
示例14: pullResource
def pullResource():
#pull for particular resource and particular languages of that resource
#languages are in one string and we split them by *// also at the end of that string we have the resource name
resourceLanguages = request.form["resourceLanguages"]
languages = resourceLanguages.split("*//")
resource = languages[-1]
logger.info("shit")
languages.pop()
prj = project.Project(path_to_tx)
try:
prj.pull(resources=[resource], fetchall=True, skip=True, languages=languages)
return "success"
except:
return "failed"
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:15,代码来源:commands.py
示例15: _get_transifex_file
def _get_transifex_file(self, directory=None):
"""Fetch the path of the .transifexrc file.
It is in the home directory ofthe user by default.
"""
if directory is None:
directory = os.path.expanduser('~')
txrc_file = os.path.join(directory, ".transifexrc")
logger.debug(".transifexrc file is at %s" % directory)
if not os.path.exists(txrc_file):
msg = "No authentication data found."
logger.info(msg)
mask = os.umask(077)
open(txrc_file, 'w').close()
os.umask(mask)
return txrc_file
开发者ID:sayanchowdhury,项目名称:transifex-client,代码行数:16,代码来源:project.py
示例16: _migrate_txrc_file
def _migrate_txrc_file(self, txrc):
"""Migrate the txrc file, if needed."""
for section in txrc.sections():
orig_hostname = txrc.get(section, 'hostname')
hostname = visit_hostname(orig_hostname)
if hostname != orig_hostname:
msg = "Hostname %s should be changed to %s."
logger.info(msg % (orig_hostname, hostname))
if (sys.stdin.isatty() and sys.stdout.isatty() and
confirm('Change it now? ', default=True)):
txrc.set(section, 'hostname', hostname)
msg = 'Hostname changed'
logger.info(msg)
else:
hostname = orig_hostname
self._save_txrc_file(txrc)
return txrc
开发者ID:gisce,项目名称:transifex-client,代码行数:17,代码来源:project.py
示例17: _auto_remote
def _auto_remote(path_to_tx, url):
"""
Initialize a remote project/resource to the current directory.
"""
logger.info("Auto configuring local project from remote URL...")
type, vars = utils.parse_tx_url(url)
prj = project.Project(path_to_tx)
username, password = prj.getset_host_credentials(vars['hostname'])
if type == 'project':
logger.info("Getting details for project %s" % vars['project'])
proj_info = utils.get_details('project_details',
username, password,
hostname = vars['hostname'], project = vars['project'])
resources = [ '.'.join([vars['project'], r['slug']]) for r in proj_info['resources'] ]
logger.info("%s resources found. Configuring..." % len(resources))
elif type == 'resource':
logger.info("Getting details for resource %s" % vars['resource'])
resources = [ '.'.join([vars['project'], vars['resource']]) ]
else:
raise("Url '%s' is not recognized." % url)
for resource in resources:
logger.info("Configuring resource %s." % resource)
proj, res = resource.split('.')
res_info = utils.get_details('resource_details',
username, password, hostname = vars['hostname'],
project = proj, resource=res)
try:
source_lang = res_info['source_language_code']
i18n_type = res_info['i18n_type']
except KeyError:
raise Exception("Remote server seems to be running an unsupported version"
" of Transifex. Either update your server software of fallback"
" to a previous version of transifex-client.")
prj.set_remote_resource(
resource=resource,
host = vars['hostname'],
source_lang = source_lang,
i18n_type = i18n_type)
prj.save()
开发者ID:mpessas,项目名称:transifex-client,代码行数:43,代码来源:commands.py
示例18: cmd_pull
def cmd_pull(argv, path_to_tx):
"Pull files from remote server to local repository"
parser = pull_parser()
(options, args) = parser.parse_args(argv)
logger.info(argv);
if options.fetchall and options.languages:
parser.error("You can't user a language filter along with the"\
" -a|--all option")
languages = parse_csv_option(options.languages)
logger.info(languages);
resources = parse_csv_option(options.resources)
skip = options.skip_errors
minimum_perc = options.minimum_perc or None
try:
_go_to_dir(path_to_tx)
except UnInitializedError, e:
utils.logger.error(e)
return
开发者ID:zaabalonso,项目名称:transifex-client,代码行数:19,代码来源:commands.py
示例19: bare_set
def bare_set(path_to_tx, options):
filename = options.filename
# Calculate relative path
path_to_file = os.path.relpath(filename, path_to_tx)
if options.is_source:
resource = options.resource
_set_source_file(path_to_tx, resource, options.language, path_to_file)
elif options.resource or options.language:
resource = options.resource
lang = options.language
_go_to_dir(path_to_tx)
_set_translation(path_to_tx, resource, lang, path_to_file)
_set_mode(options.resource, options.mode, path_to_tx)
_set_type(options.resource, options.i18n_type, path_to_tx)
_set_minimum_perc(options.resource, options.minimum_perc, path_to_tx)
logger.info("Done.")
开发者ID:transifex,项目名称:transifex-client,代码行数:20,代码来源:commands.py
示例20: cmd_push
def cmd_push(argv, path_to_tx):
"Push local files to remote server"
parser = push_parser()
(options, args) = parser.parse_args(argv)
force_creation = options.force_creation
languages = parse_csv_option(options.languages)
resources = parse_csv_option(options.resources)
skip = options.skip_errors
prj = project.Project(path_to_tx)
if not (options.push_source or options.push_translations):
parser.error("You need to specify at least one of the -s|--source,"
" -t|--translations flags with the push command.")
prj.push(
force=force_creation, resources=resources, languages=languages,
skip=skip, source=options.push_source,
translations=options.push_translations,
no_interactive=options.no_interactive
)
logger.info("Done.")
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:20,代码来源:commands.py
注:本文中的txclib.log.logger.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论