本文整理汇总了Python中utils.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scattercisr
def scattercisr(xs, ys, amoeboids, mesenchymals, labels = None, xlabel = None, ylabel = None, xlabels=None, title=None, legend=None, showGrid=False, folder=None, savefile=None, **plotargs):
assert len(xs)==len(ys), "y0 and y1 don't have the same length"
fig = plt.figure()
ax = fig.add_subplot(111)
plt.grid(showGrid)
handles = []
h0 = ax.scatter(xs[mesenchymals], ys[mesenchymals], color='g', marker='o', s=7, label="mesenchymals")
h1 = ax.scatter(xs[amoeboids], ys[amoeboids], color='b', marker='o', s=7, label="amoeboids")
handles.append(h0)
handles.append(h1)
ax.legend(loc=10)
if legend is not None:
ax.legend(handles, legend, loc=10)
if xlabel is not None:
ax.set_xlabel(xlabel)
if ylabel is not None:
ax.set_ylabel(ylabel)
if title is not None:
ax.set_title(title)
if "xlim" in plotargs.keys():
ax.set_xlim(plotargs["xlim"])
if "ylim" in plotargs.keys():
ax.set_ylim(plotargs["ylim"])
if folder is None:
folder = ""
if savefile is not None:
savefilepath = join(folder, savefile)
plt.savefig(savefilepath)
info(savefile + " written.")
if savefile is None:
plt.show()
plt.close()
示例2: plot
def plot(x, y, labels = None, xlabel = None, ylabel = None, xlabels=None, title=None, legend=None, showGrid=False, folder=None, savefile=None):
assert len(x)==len(y), "x and y don't have the same length"
assert len(x)>0 and type(x)==list
fig = plt.figure()
ax = fig.add_subplot(111)
plt.grid(showGrid)
handles = []
for i, _ in enumerate(x):
handles.append(ax.plot(x[i], y[i], linestyle=':', marker='s')[0])
#That label stuff doesn't yet work as it should.
if labels is not None:
ax.text(x[i][0], y[i][0], labels[0], horizontalalignment='left', verticalalignment='top', transform=ax.transAxes)
if legend is not None:
ax.legend(handles, legend, loc=0)
if xlabel is not None:
ax.set_xlabel(xlabel)
if ylabel is not None:
ax.set_ylabel(ylabel)
if title is not None:
ax.set_title(title)
if folder is None:
folder = ""
if savefile is not None:
plt.savefig(join(folder, savefile))
info(savefile + " written.")
if savefile is None:
plt.show()
plt.close()
示例3: bars_stacked
def bars_stacked(y0, color0, y1, color1, left, width, y_bars=None, labels = None, xlabel = None, ylabel = None, xlabels=None, title=None, legend=None, showGrid=False, folder=None, savefile=None, **plotargs):
assert len(y0)==len(y1), "y0 and y1 don't have the same length"
fig = plt.figure()
ax = fig.add_subplot(111)
plt.grid(showGrid)
handles = []
h0 = ax.bar(left, y0, width, color=color0, label="successful")
h1 = ax.bar(left, y1, width, bottom=y0, color=color1, label="unsuccessful")
handles.append(h0)
handles.append(h1)
ax.legend()
if legend is not None:
ax.legend(handles, legend, loc=0)
if xlabel is not None:
ax.set_xlabel(xlabel)
if ylabel is not None:
ax.set_ylabel(ylabel)
if title is not None:
ax.set_title(title)
if "xlim" in plotargs.keys():
ax.set_xlim(plotargs["xlim"])
if "ylim" in plotargs.keys():
ax.set_ylim(plotargs["ylim"])
if folder is None:
folder = ""
if savefile is not None:
savefilepath = join(folder, savefile)
plt.savefig(savefilepath)
info(savefile + " written.")
if savefile is None:
plt.show()
plt.close()
示例4: setup_server
def setup_server(cfg, db):
'''Setup seafile server with the setup-seafile.sh script. We use pexpect to
interactive with the setup process of the script.
'''
info('uncompressing server tarball')
shell('tar xf seafile-server_{}_x86-64.tar.gz -C {}'
.format(cfg.version, cfg.installdir))
if db == 'mysql':
autosetup_mysql(cfg)
else:
autosetup_sqlite3(cfg)
with open(join(cfg.installdir, 'conf/seahub_settings.py'), 'a') as fp:
fp.write('\n')
fp.write('DEBUG = True')
fp.write('\n')
fp.write('''\
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_RATES': {
'ping': '600/minute',
'anon': '1000/minute',
'user': '1000/minute',
},
}''')
fp.write('\n')
示例5: setup_network
def setup_network():
global tapdev
info('Configuring VM networking')
tapdev = sh_str('ifconfig tap create')
info('Using tap device {0}', tapdev)
sh('ifconfig ${tapdev} inet ${HOST_IP} ${NETMASK} up')
示例6: GetSmoothingFactor
def GetSmoothingFactor(points, hRefmethod, modifier, proportionAmount):
hRef = 0
if hRefmethod.lower() == "worton":
hRef = HrefWorton(points)
elif hRefmethod.lower() == "tufto":
hRef = HrefTufto(points)
elif hRefmethod.lower() == "silverman":
hRef = HrefSilverman(points)
elif hRefmethod.lower() == "gaussian":
hRef = HrefGaussianApproximation(points)
elif not hrefmethod or hrefmethod == "#":
hRef = HrefWorton(points)
if hRef == 0:
utils.die("No valid hRef method was provided. Quitting.")
if modifier.lower() == "proportion":
h = proportionAmount * hRef
elif modifier.lower() == "lscv":
h = Minimize(LSCV, hRef, points)
elif modifier.lower() == "bcv2":
h = Minimize(BCV2, hRef, points)
else:
h = hRef
utils.info("hRef (" + hRefmethod + ") = " + str(hRef))
utils.info("Using h = " + str(h))
return h
示例7: symfony_fix_permissions
def symfony_fix_permissions():
with settings(warn_only=True):
if run('test -d %s/app/cache' % env.project_path).succeeded:
info('fixing cache and logs permissions')
www_user = run('ps aux | grep -E \'nginx\' | grep -v root | head -1 | cut -d\ -f1')
sudo('setfacl -R -m u:%(www_user)s:rwX -m u:$(whoami):rwX %(project_path)s/app/cache %(project_path)s/app/logs' % { 'www_user': www_user, 'project_path': env.project_path })
sudo('setfacl -dR -m u:%(www_user)s:rwX -m u:$(whoami):rwX %(project_path)s/app/cache %(project_path)s/app/logs' % { 'www_user': www_user, 'project_path': env.project_path })
示例8: unbindFeature
def unbindFeature(self, qgsfeature, editingmode=False):
"""
Unbinds the feature from the form saving the values back to the QgsFeature.
qgsfeature -- A QgsFeature that will store the new values.
"""
savefields = []
for index, control in self.fieldtocontrol.items():
value = QVariant()
if isinstance(control, QDateTimeEdit):
value = control.dateTime().toString(Qt.ISODate)
else:
if self.layer.editType(index) == QgsVectorLayer.UniqueValues and control.isEditable():
# Due to http://hub.qgis.org/issues/7012 we can't have editable
# comboxs using QgsAttributeEditor. If the value isn't in the
# dataset already it will return null. Until that bug is fixed
# we are just going to handle ourself.
value = control.currentText()
else:
modified = QgsAttributeEditor.retrieveValue(control, self.layer, index, value)
info("Setting value to %s from %s" % (value, control.objectName()))
qgsfeature.changeAttribute(index, value)
# Save the value to the database as a default if it is needed.
if self.shouldSaveValue(control):
savefields.append(index)
if not editingmode:
m = qgsfeature.attributeMap()
fields_map = self.layer.pendingFields()
attr = {str(fields_map[k].name()): str(v.toString()) for k, v in m.items() if k in savefields}
self.form.setSavedValues(attr)
return qgsfeature
示例9: _update_from_iter
def _update_from_iter(self):
if self.it != None:
self.file = self.tree.get_model().get_value(self.it, 1)
if self.tree.get_model().get_value(self.it, 9):
# FIXME: Controlla se esiste gia il file(se l'abbiamo scaricato precedentemente)
tmp = os.path.join(utils.UPDT_DIR, self.file)
if os.path.exists(tmp):
# Controlliamo se il file e' corretto
bytes = os.path.getsize(tmp)
md5 = generate.Generator.checksum(tmp)
if md5 != self.tree.get_model().get_value(self.it, 4) or int(bytes) != self.tree.get_model().get_value(self.it, 3):
os.remove(tmp)
self._thread(self._update_file, utils.url_encode(BASE_DIR + self.file))
else:
self._update_percentage()
self._go_with_next_iter()
else:
self._thread(self._update_file, utils.url_encode(BASE_DIR + self.file))
else:
self._update_percentage()
self._go_with_next_iter()
else:
self.xml_util.dump_tree_to_file(self.diff_object, os.path.join(utils.UPDT_DIR, ".diff.xml"))
utils.info(_("Riavvia per procedere all'aggiornamento di PyAcqua"))
self.destroy()
示例10: kill_me_later
def kill_me_later(timeout, extra_time=60):
pid = os.getpid()
if os.fork() != 0:
return
signal.signal(signal.SIGINT, signal.SIG_IGN)
int_deadline = datetime.now() + timedelta(seconds=timeout)
kill_deadline = int_deadline + timedelta(seconds=extra_time)
int_sent = False
while True:
time.sleep(1)
now = datetime.now()
try:
if now < int_deadline:
os.kill(pid, 0) # Just poll the process
elif now < kill_deadline:
utils.info("execution timeout reached, interrupting")
os.kill(pid, signal.SIGINT if not int_sent else 0)
int_sent = True
else:
utils.info("execution timeout reached, killing")
os.kill(pid, signal.SIGKILL)
break
except OSError: # The process terminated
break
exit(0)
示例11: _run_theta_single
def _run_theta_single(name, debug):
cache_dir = os.path.join(global_config.workdir, 'cache')
cfgfile = name + '.cfg'
dbfile = name + '.db'
cfgfile_cache = os.path.join(cache_dir, cfgfile)
dbfile_cache = os.path.join(cache_dir, dbfile)
cfgfile_full = os.path.join(global_config.workdir, cfgfile)
already_done = False
theta = os.path.realpath(os.path.join(global_config.theta_dir, 'bin', 'theta'))
if os.path.exists(cfgfile_cache) and os.path.exists(os.path.join(cache_dir, dbfile)):
# compare the config files:
already_done = open(cfgfile_cache, 'r').read() == open(cfgfile_full, 'r').read()
if already_done:
utils.info("Skipping 'theta %s': found corresponding output file in cachedir" % cfgfile)
return
utils.info("Running 'theta %s'" % cfgfile)
params = ""
#if debug: params += " --redirect-io=False"
retval = os.system(theta + params + " " + cfgfile_full)
if retval != 0:
if os.isatty(1):
attr = termios.tcgetattr(1)
attr[3] |= termios.ECHO
termios.tcsetattr(1, termios.TCSANOW, attr)
if os.path.exists(dbfile) and not debug: os.unlink(dbfile)
raise RuntimeError, "executing theta for cfg file '%s' failed with exit code %d" % (cfgfile, retval)
# move to cache, also the config file ...
shutil.move(dbfile, dbfile_cache)
shutil.copy(cfgfile_full, cfgfile_cache)
示例12: setup_rootfs
def setup_rootfs():
buildkernel(e('${KERNCONF}-DEBUG'), ['mach'], buildkernellog)
installworld('${OBJDIR}/test-root', installworldlog, distributionlog, conf="run")
installkernel(e('${KERNCONF}'), '${OBJDIR}/test-root', installkernellog, modules=['mach'], conf="run")
info('Installing overlay files')
sh('rsync -ah ${TESTS_ROOT}/trueos/overlay/ ${OBJDIR}/test-root')
sh('makefs -M ${IMAGE_SIZE} ${OBJDIR}/test-root.ufs ${OBJDIR}/test-root')
示例13: upload
def upload(directory):
"""Upload a directory to S3.
DIRECTORY: Directory to upload. Required.
"""
if not AWS_BUCKET:
utils.error('AWS_BUCKET environment variable not set. Exiting.')
return
conn = S3Connection()
bucket = get_or_create_bucket(conn, AWS_BUCKET)
files = list(utils.get_files(directory))
total_size = 0
utils.info('Found', len(files), 'files to upload to s3://' + AWS_BUCKET)
for path in files:
filesize = os.path.getsize(path)
total_size += filesize
utils.info('Uploading', path, '-', sizeof_fmt(filesize))
k = Key(bucket)
k.key = path
k.set_contents_from_filename(path)
utils.success('Done. Uploaded', sizeof_fmt(total_size))
示例14: export
def export(self, targz: str, **kwargs: dict):
if not os.path.isdir(self.path):
utils.fail("%s: VM does not exist" % self.name)
exit(1)
if not targz:
targz = '%s.tar.gz' % self.name
targz = os.path.abspath(targz)
utils.info("exporting to %s" % targz)
tar = '%s/%s' % (self.path, os.path.basename(os.path.splitext(targz)[0]))
if os.path.exists(targz):
utils.fail("%s: package already exists" % targz)
exit(1)
os.chdir(self.path) # create intermediate files in VM's path
utils.pend("package disk image")
utils.execute(['tar', '-cSf', tar, os.path.basename(self.path_raw)])
utils.ok()
for s in self.snapshots:
utils.pend("package snapshot: %s" % s)
local_snapshot = '%s.%s' % (os.path.basename(self.path_raw), s)
utils.execute(['tar', '-rf', tar, local_snapshot])
utils.ok()
utils.pend("compress package", msg="may take some time")
utils.execute(['gzip', '-c', tar], outfile=targz)
utils.ok()
utils.pend("clean up")
os.unlink(tar)
utils.ok()
self.scan_snapshots()
示例15: output
def output(self, output_formats, **output_options):
"""
output all results to appropriate URLs
- output_formats: a dict mapping formats to a list of URLs
- output_options: a dict mapping formats to options for each format
"""
utils.info("Outputting talos results => %s", output_formats)
tbpl_output = {}
try:
for key, urls in output_formats.items():
options = output_options.get(key, {})
_output = output.formats[key](self, **options)
results = _output()
for url in urls:
_output.output(results, url, tbpl_output)
except utils.talosError, e:
# print to results.out
try:
_output = output.GraphserverOutput(self)
results = _output()
_output.output('file://%s' % os.path.join(os.getcwd(), 'results.out'), results)
except:
pass
print '\nFAIL: %s' % e.msg.replace('\n', '\nRETURN:')
raise e