本文整理汇总了Python中tqdm.tqdm.write函数的典型用法代码示例。如果您正苦于以下问题:Python write函数的具体用法?Python write怎么用?Python write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_commits
def get_commits(pr_number, owner='gisce', repository='erp'):
# Pagination documentation: https://developer.github.com/v3/#pagination
def parse_github_links_header(links_header):
ret_links = {}
full_links = links_header.split(',')
for link in full_links:
link_url, link_ref = link.split(';')
link_url = link_url.strip()[1:-1]
link_ref = link_ref.split('=')[-1].strip()[1:-1]
ret_links[link_ref] = link_url
return ret_links
logger.info('Getting commits from GitHub')
headers = {'Authorization': 'token %s' % github_config()['token']}
repo = github_config(
repository='{}/{}'.format(owner, repository))['repository']
url = "https://api.github.com/repos/%s/pulls/%s/commits?per_page=100" \
% (repo, pr_number)
r = requests.get(url, headers=headers)
commits = json.loads(r.text)
if 'link' in r.headers:
url_page = 1
links = parse_github_links_header(r.headers['link'])
while links['last'][-1] != str(url_page):
url_page += 1
tqdm.write(colors.yellow(
' - Getting extra commits page {}'.format(url_page)))
r = requests.get(links['next'], headers=headers)
commits += json.loads(r.text)
return commits
开发者ID:gisce,项目名称:apply_pr,代码行数:30,代码来源:fabfile.py
示例2: check_it_exists
def check_it_exists(src='/home/erp/src', repository='erp', sudo_user='erp'):
with settings(hide('everything'), sudo_user=sudo_user, warn_only=True):
res = sudo("ls {}/{}".format(src, repository))
if res.return_code:
message = "The repository does not exist or cannot be found"
tqdm.write(colors.red(message))
abort(message)
开发者ID:gisce,项目名称:apply_pr,代码行数:7,代码来源:fabfile.py
示例3: catch_result
def catch_result(self, result):
for line in result.split('\n'):
if re.match('Applying: ', line):
tqdm.write(colors.green(line))
self.pbar.update()
if result.failed:
if "git config --global user.email" in result:
logger.error(
"Need to configure git for this user\n"
)
raise GitHubException(result)
try:
raise WiggleException
except WiggleException:
if self.auto_exit:
sudo("git am --abort")
logger.error('Aborting deploy and go back')
raise GitHubException
prompt("Manual resolve...")
finally:
if not self.auto_exit:
to_commit = sudo(
"git diff --cached --name-only --no-color", pty=False
)
if to_commit:
self.resolve()
else:
self.skip()
开发者ID:gisce,项目名称:apply_pr,代码行数:28,代码来源:fabfile.py
示例4: resync_invoiceitems
def resync_invoiceitems(apps, schema_editor):
"""
Since invoiceitem IDs were not previously stored (the ``stripe_id`` field held the id of the linked subsription),
a direct migration will leave us with a bunch of orphaned objects. It was decided
[here](https://github.com/kavdev/dj-stripe/issues/162) that a purge and re-sync would be the best option for
subscriptions. That's being extended to InvoiceItems. No data that is currently available on stripe will be
deleted. Anything stored locally will be purged.
"""
# This is okay, since we're only doing a forward migration.
from djstripe.models import InvoiceItem
from djstripe.context_managers import stripe_temporary_api_version
with stripe_temporary_api_version("2016-03-07"):
if InvoiceItem.objects.count():
print("Purging invoiceitems. Don't worry, all invoiceitems will be re-synced from stripe. Just in case you \
didn't get the memo, we'll print out a json representation of each object for your records:")
print(serializers.serialize("json", InvoiceItem.objects.all()))
InvoiceItem.objects.all().delete()
print("Re-syncing invoiceitems. This may take a while.")
for stripe_invoiceitem in tqdm(iterable=InvoiceItem.api_list(), desc="Sync", unit=" invoiceitems"):
invoice = InvoiceItem.sync_from_stripe_data(stripe_invoiceitem)
if not invoice.customer:
tqdm.write("The customer for this invoiceitem ({invoiceitem_id}) does not exist \
locally (so we won't sync the invoiceitem). You'll want to figure out how that \
happened.".format(invoiceitem_id=stripe_invoiceitem['id']))
print("InvoiceItem re-sync complete.")
开发者ID:cloudsmith-io,项目名称:dj-stripe,代码行数:32,代码来源:0012_model_sync.py
示例5: tprint
def tprint(string):
"""Print string via `tqdm` so that it doesnt interfere with a progressbar.
"""
try:
tqdm.write(string)
except:
print(string)
开发者ID:astrocatalogs,项目名称:astrocats,代码行数:7,代码来源:tq_funcs.py
示例6: tpv2tan_hdr
def tpv2tan_hdr(img, ota):
image = odi.reprojpath+'reproj_'+ota+'.'+img.stem()
# change the CTYPENs to be TANs if they aren't already
tqdm.write('TPV -> TAN in {:s}'.format(image))
iraf.imutil.hedit.setParam('images',image)
iraf.imutil.hedit.setParam('fields','CTYPE1')
iraf.imutil.hedit.setParam('value','RA---TAN')
iraf.imutil.hedit.setParam('add','yes')
iraf.imutil.hedit.setParam('addonly','no')
iraf.imutil.hedit.setParam('verify','no')
iraf.imutil.hedit.setParam('update','yes')
iraf.imutil.hedit(show='no', mode='h')
iraf.imutil.hedit.setParam('images',image)
iraf.imutil.hedit.setParam('fields','CTYPE2')
iraf.imutil.hedit.setParam('value','DEC--TAN')
iraf.imutil.hedit.setParam('add','yes')
iraf.imutil.hedit.setParam('addonly','no')
iraf.imutil.hedit.setParam('verify','no')
iraf.imutil.hedit.setParam('update','yes')
iraf.imutil.hedit(show='no', mode='h')
# delete any PV keywords
# leaving them in will give you trouble with the img wcs
iraf.unlearn(iraf.imutil.hedit)
iraf.imutil.hedit.setParam('images',image)
iraf.imutil.hedit.setParam('fields','PV*')
iraf.imutil.hedit.setParam('delete','yes')
iraf.imutil.hedit.setParam('verify','no')
iraf.imutil.hedit.setParam('update','yes')
iraf.imutil.hedit(show='no', mode='h')
开发者ID:bjanesh,项目名称:odi-tools,代码行数:31,代码来源:odi_helpers.py
示例7: check_trace
def check_trace(self, step_method):
"""Tests whether the trace for step methods is exactly the same as on master.
Code changes that effect how random numbers are drawn may change this, and require
`master_samples` to be updated, but such changes should be noted and justified in the
commit.
This method may also be used to benchmark step methods across commits, by running, for
example
```
BENCHMARK=100000 ./scripts/test.sh -s pymc3/tests/test_step.py:TestStepMethods
```
on multiple commits.
"""
test_steps = 100
n_steps = int(os.getenv('BENCHMARK', 100))
benchmarking = (n_steps != test_steps)
if benchmarking:
tqdm.write('Benchmarking {} with {:,d} samples'.format(step_method.__name__, n_steps))
else:
tqdm.write('Checking {} has same trace as on master'.format(step_method.__name__))
with Model():
Normal('x', mu=0, sd=1)
trace = sample(n_steps, step=step_method(), random_seed=1)
if not benchmarking:
assert_array_almost_equal(trace.get_values('x'), self.master_samples[step_method])
开发者ID:sjtu2008,项目名称:pymc3,代码行数:29,代码来源:test_step.py
示例8: check_alignments
def check_alignments(self, filename):
""" If we have no alignments for this image, skip it """
have_alignments = self.faces.have_face(filename)
if not have_alignments:
tqdm.write("No alignment found for {}, "
"skipping".format(os.path.basename(filename)))
return have_alignments
开发者ID:Nioy,项目名称:faceswap,代码行数:7,代码来源:convert.py
示例9: mal
def mal(mal_title, mal_id=False):
cookies = {"incap_ses_224_81958":"P6tYbUr7VH9V6shgudAbA1g5FVYAAAAAyt7eDF9npLc6I7roc0UIEQ=="}
response = requests.get(
"http://myanimelist.net/api/anime/search.xml",
params={'q':mal_title},
cookies=cookies,
auth=("zodman1","zxczxc"),
headers = {'User-Agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36'})
content = response.content
if not mal_id is False:
for e in xpath.search(content,"//entry"):
if mal_id in e:
content = e
break
tqdm.write("%s %s"%((mal_title,), mal_id))
id = xpath.get(content, "//id")
title = xpath.get(content, "//title")
title_en = xpath.get(content, "//english")
type_ = xpath.get(content, "//type")
synonyms = xpath.get(content, "//synonyms")
status = xpath.get(content, "//status")
synopsys = translate(xpath.get(content, "//synopsis"),"es")
img = xpath.get(content, "//image")
episodes = xpath.get(content,"//episodes")
resumen = synopsys.replace("<br />", " ").replace("\n\r","")
resumen = translate(resumen,'es')
status = translate(status,'es')
assert id is not "", mal_title
data=dict(title=title, title_en=title_en, type=type_, status=status,
resumen=resumen, img=img,episodes=episodes, synonyms=synonyms,id=id, synopsys=synopsys)
return MalResult(**data)
开发者ID:zodman,项目名称:nyaa_indexer,代码行数:33,代码来源:utils.py
示例10: resync_subscriptions
def resync_subscriptions(apps, schema_editor):
"""
Since subscription IDs were not previously stored, a direct migration will leave us
with a bunch of orphaned objects. It was decided [here](https://github.com/kavdev/dj-stripe/issues/162)
that a purge and re-sync would be the best option. No data that is currently available on stripe will
be deleted. Anything stored locally will be purged.
"""
# This is okay, since we're only doing a forward migration.
from djstripe.models import Subscription
from djstripe.context_managers import stripe_temporary_api_version
with stripe_temporary_api_version("2016-03-07"):
if Subscription.objects.count():
print("Purging subscriptions. Don't worry, all active subscriptions will be re-synced from stripe. Just in \
case you didn't get the memo, we'll print out a json representation of each object for your records:")
print(serializers.serialize("json", Subscription.objects.all()))
Subscription.objects.all().delete()
print("Re-syncing subscriptions. This may take a while.")
for stripe_subscription in tqdm(iterable=Subscription.api_list(), desc="Sync", unit=" subscriptions"):
subscription = Subscription.sync_from_stripe_data(stripe_subscription)
if not subscription.customer:
tqdm.write("The customer for this subscription ({subscription_id}) does not exist locally (so we \
won't sync the subscription). You'll want to figure out how that \
happened.".format(subscription_id=stripe_subscription['id']))
print("Subscription re-sync complete.")
开发者ID:cloudsmith-io,项目名称:dj-stripe,代码行数:31,代码来源:0012_model_sync.py
示例11: handle_single
def handle_single(self, filename, verbosity, remove):
tqdm.write("Work on {!r}".format(filename))
basename = os.path.splitext(os.path.basename(filename))[0]
tree = ET.parse(filename)
root = tree.getroot()
words = defaultdict(lambda: {'words': set(), 'fichas': list()})
fichas = root.findall('./ficha')
for ficha in tqdm(fichas, desc=basename, leave=False):
lemma = ''.join(ficha.find('./lema').itertext()).strip()
data = ImportSM.work_on_ficha(ficha)
data = [it[0] for it in data]
for it in data:
try:
w = Word.objects.get(word=it.encode('utf-8'))
words[w.pk]['words'].add(it)
words[w.pk]['fichas'].append((filename, ficha.attrib['ID'], ficha))
except Word.DoesNotExist:
tqdm.write("not found {}".format(lemma))
# Detect duplicates!
dupes = {k: v for k, v in words.items() if len(v['words']) > 1}
if dupes:
remove_msg = " (will be removed!)"
tqdm.write("...found {} duplicates{}".format(len(dupes), remove_msg))
for w, values in dupes.items():
word = Word.objects.get(pk=w)
tqdm.write(" - pk: {!r}: {}".format(w, word))
for ficha in values['fichas']:
tqdm.write(" + {}: [ID={!r}] {}".format(ficha[0], ficha[1], ''.join(ficha[2].find('./lema').itertext()).strip()))
if remove:
word.delete()
开发者ID:jgsogo,项目名称:neutron,代码行数:35,代码来源:bugfix_duplicated_words.py
示例12: _print_epoch_means
def _print_epoch_means(self):
last_val_accs = np.array(self.validation_accuracies)
v_mean = np.mean(last_val_accs[-801:-1])
last_train_accs = np.array(self.train_accuracies)
t_mean = np.mean(last_train_accs[-801:-1])
#tqdm.write('EPOCH %d:'%(self.epoch))
tqdm.write('training => %.5f / val => %.5f'%(t_mean,v_mean))
开发者ID:darolt,项目名称:deeplearning,代码行数:7,代码来源:tfhelper.py
示例13: check_alignments
def check_alignments(self, frame):
""" If we have no alignments for this image, skip it """
have_alignments = self.alignments.frame_exists(frame)
if not have_alignments:
tqdm.write("No alignment found for {}, "
"skipping".format(frame))
return have_alignments
开发者ID:stonezuohui,项目名称:faceswap,代码行数:7,代码来源:convert.py
示例14: emit
def emit(self, record):
try:
msg = self.format(record)
tqdm.write(msg, file=self.stream, end=self.terminator)
self.flush()
except Exception: # pylint: disable=broad-except
self.handleError(record)
开发者ID:wmayner,项目名称:pyphi,代码行数:7,代码来源:log.py
示例15: get_exec_times
def get_exec_times(graph):
# Get execution times for reports (-m option)
basename,_ = os.path.splitext(os.path.basename(graph))
reports = glob.glob("*"+basename + "*.csv")
reports.sort(reverse=True, key= lambda f: os.path.getmtime(f))
csvfile = reports[0]
tqdm.write("Retrieving monitoring info from "+ csvfile)
return get_costs(csvfile)
开发者ID:programLyrique,项目名称:audio-adaptive-scheduling,代码行数:8,代码来源:pipeline.py
示例16: train
def train(self, episodes=500, max_step=200):
for episode in tqdm(range(episodes)):
if episode % 50 == 0:
total_reward = self._test_impl(max_step, delay=0, gui=False)
tqdm.write('current reward: {total_reward}'.format(total_reward=total_reward))
else:
# train step
self._train_impl(max_step)
开发者ID:BossKwei,项目名称:temp,代码行数:8,代码来源:dqn2013.py
示例17: check_am_session
def check_am_session(src='/home/erp/src', repository='erp', sudo_user='erp'):
with settings(hide('everything'), sudo_user=sudo_user, warn_only=True):
with cd("{}/{}".format(src, repository)):
res = sudo("ls .git/rebase-apply")
if not res.return_code:
message = "The repository is in the middle of an am session!"
tqdm.write(colors.red(message))
abort(message)
开发者ID:gisce,项目名称:apply_pr,代码行数:8,代码来源:fabfile.py
示例18: check_is_rolling
def check_is_rolling(src='/home/erp/src', repository='erp', sudo_user='erp'):
with settings(hide('everything'), sudo_user=sudo_user, warn_only=True):
with cd("{}/{}".format(src, repository)):
res = sudo("git branch | grep '* rolling'")
if res.return_code:
message = "The repository is not in rolling mode"
tqdm.write(colors.red(message))
abort(message)
开发者ID:gisce,项目名称:apply_pr,代码行数:8,代码来源:fabfile.py
示例19: _write
def _write(self, msg):
"""
Write error messages to the progress bar, if using one,
otherwise to stderr
"""
if self._progbar:
tqdm.write(msg)
else:
print(msg, file= sys.stderr)
开发者ID:gjoseph92,项目名称:soundDB,代码行数:9,代码来源:accessor.py
示例20: _saveSession
def _saveSession(self, sess):
""" Save the model parameters and the variables
Args:
sess: the current session
"""
tqdm.write('Checkpoint reached: saving model (don\'t stop the run)...')
self.saveModelParams()
self.saver.save(sess, self._getModelName()) # TODO: Put a limit size (ex: 3GB for the modelDir)
tqdm.write('Model saved.')
开发者ID:DavidSchott,项目名称:ChatBot,代码行数:9,代码来源:chatbot.py
注:本文中的tqdm.tqdm.write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论