本文整理汇总了Python中setproctitle.getproctitle函数的典型用法代码示例。如果您正苦于以下问题:Python getproctitle函数的具体用法?Python getproctitle怎么用?Python getproctitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getproctitle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_obfuscate_process_password
def test_obfuscate_process_password():
original_title = setproctitle.getproctitle()
setproctitle.setproctitle("pgcli user=root password=secret host=localhost")
obfuscate_process_password()
title = setproctitle.getproctitle()
expected = "pgcli user=root password=xxxx host=localhost"
assert title == expected
setproctitle.setproctitle("pgcli user=root password=top secret host=localhost")
obfuscate_process_password()
title = setproctitle.getproctitle()
expected = "pgcli user=root password=xxxx host=localhost"
assert title == expected
setproctitle.setproctitle("pgcli user=root password=top secret")
obfuscate_process_password()
title = setproctitle.getproctitle()
expected = "pgcli user=root password=xxxx"
assert title == expected
setproctitle.setproctitle("pgcli postgres://root:[email protected]/db")
obfuscate_process_password()
title = setproctitle.getproctitle()
expected = "pgcli postgres://root:[email protected]/db"
assert title == expected
setproctitle.setproctitle(original_title)
开发者ID:danieljwest,项目名称:pgcli,代码行数:28,代码来源:test_main.py
示例2: _save_process_pid
def _save_process_pid(self):
"""
Changes the progress title adding a -PID_%PID parameter
"""
if sys.platform.startswith('linux2'):
import setproctitle
title = setproctitle.getproctitle()
setproctitle.setproctitle("%s -PID_%s" % (title, os.getpid()))
new_title = setproctitle.getproctitle()
self.logger.info("Current proc title is %s" % new_title)
开发者ID:alepharchives,项目名称:FileRock-Client,代码行数:10,代码来源:application.py
示例3: main
def main():
print(str.format(
'[-] Current process name: {}', setproctitle.getproctitle()
))
setproctitle.setproctitle('arheo_process')
print(str.format(
'[-] After change process name: {}',
setproctitle.getproctitle()
))
time.sleep(10)
开发者ID:arheo,项目名称:python_core,代码行数:12,代码来源:app1.py
示例4: test_lifecycle
def test_lifecycle(self):
t = setproctitle.getproctitle()
try:
p = progress.Proctitle()
self.assertEqual(t, setproctitle.getproctitle())
p('')
self.assertEqual('bigitrd ', setproctitle.getproctitle())
p('foo')
self.assertEqual('bigitrd foo', setproctitle.getproctitle())
finally:
del p
self.assertEqual(t, setproctitle.getproctitle())
开发者ID:mikjo,项目名称:bigitr,代码行数:12,代码来源:progress_test.py
示例5: __init__
def __init__(self, configfile):
# Initialize Logging
self.log = logging.getLogger('diamond')
# Initialize Members
self.configfile = configfile
self.config = None
# We do this weird process title swap around to get the sync manager
# title correct for ps
if setproctitle:
oldproctitle = getproctitle()
setproctitle('%s - SyncManager' % getproctitle())
if setproctitle:
setproctitle(oldproctitle)
开发者ID:ChristianKniep,项目名称:QNIBCollect,代码行数:14,代码来源:server.py
示例6: _format_exception_message
def _format_exception_message(cls, msg, pid):
return cls._EXCEPTION_LOG_FORMAT.format(
timestamp=cls._iso_timestamp_for_now(),
process_title=setproctitle.getproctitle(),
args=sys.argv,
pid=pid,
message=msg)
开发者ID:jsirois,项目名称:pants,代码行数:7,代码来源:exception_sink.py
示例7: periodic_aggregated_stats_logger
def periodic_aggregated_stats_logger(cls):
hostname = socket.gethostname()
service_name = '_'.join(setproctitle.getproctitle().split('_')[:-1])
logd = cls._stats.to_dict()
logs = []
for server_type in ['http', 'tcp']:
try:
server_type_d = logd['sub'][server_type]['sub']
except KeyError:
continue
for k, v in server_type_d.items():
d = dict({
'method': k,
'server_type': server_type,
'hostname': hostname,
'service_name': service_name,
'average_response_time': v['average'],
'total_request_count': v['count'],
'success_count': v['success_count']
})
for k2, v2 in v['sub'].items():
d['CODE_{}'.format(k2)] = v2['count']
logs.append(d)
_logger = logging.getLogger('stats')
for logd in logs:
_logger.info(dict(logd))
asyncio.get_event_loop().call_later(300, cls.periodic_aggregated_stats_logger)
开发者ID:bgupta1mg,项目名称:vyked,代码行数:30,代码来源:stats.py
示例8: periodic_aggregated_stats_logger
def periodic_aggregated_stats_logger(cls):
hostname = socket.gethostname()
service_name = "_".join(setproctitle.getproctitle().split("_")[:-1])
logd = cls._stats.to_dict()
logs = []
for server_type in ["http", "tcp"]:
try:
server_type_d = logd["sub"][server_type]["sub"]
except KeyError:
continue
for k, v in server_type_d.items():
d = dict(
{
"method": k,
"server_type": server_type,
"hostname": hostname,
"service_name": service_name,
"average_response_time": v["average"],
"total_request_count": v["count"],
"success_count": v["success_count"],
}
)
for k2, v2 in v["sub"].items():
d["CODE_{}".format(k2)] = v2["count"]
logs.append(d)
_logger = logging.getLogger("stats")
for logd in logs:
_logger.info(dict(logd))
asyncio.get_event_loop().call_later(300, cls.periodic_aggregated_stats_logger)
开发者ID:nerandell,项目名称:vyked,代码行数:32,代码来源:stats.py
示例9: appendproctitle
def appendproctitle(name):
'''
Append "name" to the current process title
From: https://github.com/saltstack/salt/blob/v2014.7.1/salt/utils/__init__.py#L2377
'''
if HAS_SETPROCTITLE:
setproctitle.setproctitle(setproctitle.getproctitle() + ' ' + name)
开发者ID:MarloweW,项目名称:salt-broker,代码行数:8,代码来源:__init__.py
示例10: session
def session(uri, sync=False, autoflush=False, expire_on_commit=False):
''' Returns a managed session to the postgres server. '''
application_name = ('%s:%s:%05d' % (getproctitle(), socket.gethostname(), os.getpid()))[-63:]
connect_args = {'application_name': application_name}
engine = create_engine(uri, connect_args=connect_args, poolclass=StaticPool)
with ManagedSession(engine, autoflush=autoflush, expire_on_commit=expire_on_commit) as sesh:
sesh.execute('SET synchronous_commit TO OFF;') if not sync else None
yield sesh
开发者ID:kjson,项目名称:gargantis,代码行数:8,代码来源:postgres.py
示例11: obfuscate_process_password
def obfuscate_process_password():
process_title = setproctitle.getproctitle()
if '://' in process_title:
process_title = re.sub(r":(.*):(.*)@", r":\1:[email protected]", process_title)
elif "=" in process_title:
process_title = re.sub(r"password=(.+?)((\s[a-zA-Z]+=)|$)", r"password=xxxx\2", process_title)
setproctitle.setproctitle(process_title)
开发者ID:vinotheassassin,项目名称:pgcli,代码行数:8,代码来源:main.py
示例12: format
def format(self, record):
"""Prepends current process name to ``record.name`` if running in the
context of a taskd process that is currently processing a task.
"""
title = getproctitle()
if title.startswith('taskd:'):
record.name = "{0}:{1}".format(title, record.name)
return super(CustomWatchedFileHandler, self).format(record)
开发者ID:apache,项目名称:incubator-allura,代码行数:9,代码来源:utils.py
示例13: start_poller
def start_poller(proc_id, carbon_queue, job_queue):
proc_title = setproctitle.getproctitle()
setproctitle.setproctitle("%s - poller#%s" % (proc_title, proc_id))
logger.debug("start start_poller()")
while True:
lauch_time, job = job_queue.get()
launch_timedelta = lauch_time - int(time())
if launch_timedelta > 0:
logger.debug("sleep %s", launch_timedelta)
sleep(launch_timedelta)
else:
logger.warning("lateness %s's", launch_timedelta)
poll_start = int(time())
logger.warning("--polling--")
config = job.config
hosts = job.hosts
# get indexes in first poll
index_oids = config['indexes'].keys()
if index_oids:
index_oids_group = [(oid,) for oid in list(index_oids)]
snmp_data = snmp_poller.poller(hosts, index_oids_group, COMMUNITY)
index_table = defaultdict_rec()
for snmp_res in snmp_data:
host, base_oid, index_part, value = snmp_res
index_name = config['indexes'][base_oid]
index_table[host][index_name][index_part] = normalize_ifname(value)
target_oid_indexes = {}
target_oid_metric_pfx = {}
for target_oid in config['target_oids']:
if 'index_name' in target_oid:
target_oid_indexes[target_oid['oid']] = target_oid['index_name']
target_oid_metric_pfx[target_oid['oid']] = target_oid['metric_prefix']
# get other in second poll
oids_group = [(oid['oid'],) for oid in config['target_oids']]
snmp_data = snmp_poller.poller(hosts, oids_group, COMMUNITY)
request_time = int(time())
for snmp_res in snmp_data:
host, base_oid, index_part, value = snmp_res
if index_table[host][target_oid_indexes[base_oid]][index_part]:
oid_index_name = index_table[host][target_oid_indexes[base_oid]][index_part]
else:
oid_index_name = '%s' % index_part
metric_pfx = target_oid_metric_pfx[base_oid]
short_hostname = normalize_hostname(host)
if "{index}" in metric_pfx:
metric = ("%s.%s" % (short_hostname, metric_pfx.format(index=oid_index_name)))
else:
metric = ("%s.%s.%s" % (short_hostname, metric_pfx, oid_index_name))
# print (metric, value, request_time)
msg = "%s %s %s\n" % (metric, value, request_time)
carbon_queue.put(msg)
logger.debug("polling executed in %s's", int(time()) - poll_start)
开发者ID:nix8,项目名称:fastsnmp,代码行数:56,代码来源:graphite_sender.py
示例14: format
def format(self, record):
"""
Format a log record
:param record:
"""
if _setproctitle_is_available:
record.__dict__['process_title'] = setproctitle.getproctitle()
else:
record.__dict__['process_title'] = sys.argv[0]
return logging.Formatter.format(self, record)
开发者ID:bclermont,项目名称:gsyslog,代码行数:10,代码来源:formatters.py
示例15: __init__
def __init__(self, configfile):
# Initialize Logging
self.log = logging.getLogger('diamond')
# Initialize Members
self.configfile = configfile
self.config = None
self.handlers = []
self.handler_queue = []
self.modules = {}
# We do this weird process title swap around to get the sync manager
# title correct for ps
if setproctitle:
oldproctitle = getproctitle()
setproctitle('%s - SyncManager' % getproctitle())
self.manager = multiprocessing.Manager()
if setproctitle:
setproctitle(oldproctitle)
self.metric_queue = self.manager.Queue()
开发者ID:underarmour,项目名称:Diamond,代码行数:19,代码来源:server.py
示例16: obfuscate_process_password
def obfuscate_process_password():
process_title = setproctitle.getproctitle()
if "://" in process_title:
process_title = re.sub(r":(.*):(.*)@", r":\1:[email protected]", process_title)
elif "=" in process_title:
process_title = re.sub(r"password=(.+?)(\s|$)", r"password=xxxx\2", process_title)
elif "-w" in process_title:
process_title = re.sub(r"\-w\s+([^\s]+)(\s|$)", r"-w xxxx\2", process_title)
setproctitle.setproctitle(process_title)
开发者ID:dbcli,项目名称:vcli,代码行数:10,代码来源:main.py
示例17: title
def title(cls, message=None, level='INFO'):
'''Set the title of the process'''
if message == None:
return getproctitle()
else:
setproctitle('qless-py-worker %s' % message)
if level == 'DEBUG':
logger.debug(message)
elif level == 'INFO':
logger.info(message)
开发者ID:Contatta,项目名称:qless-py,代码行数:10,代码来源:__init__.py
示例18: proc_init_run
def proc_init_run(procnum, func, args, kwargs):
"""
Set the process title and run.
"""
title = spt.getproctitle()
title = "{} : {} : {}".format(title, procnum, func.__name__)
spt.setproctitle(title)
return func(*args, **kwargs)
开发者ID:parantapa,项目名称:pypb,代码行数:10,代码来源:spawn.py
示例19: proctitle
def proctitle(title):
"""Temporarily change the process title, then restore it."""
orig_title = getproctitle()
try:
setproctitle(title)
yield
setproctitle(orig_title)
except:
setproctitle(orig_title)
raise
开发者ID:apache,项目名称:allura,代码行数:10,代码来源:taskd.py
示例20: __init__
def __init__(self,config,threadid,q):
Process.__init__(self)
self.threadid = threadid
self.q = q
# Initialize Logging
self.log = logging.getLogger('metrichammer')
# Initialize Members
#self.configfile = configfile
self.config = config
self.proto = 'tcp'
self.host = self.config['server']['host']
self.port = int(self.config['server']['port'])
self.socket = None
self.keepalive = 0
self.keepaliveinterval = int(self.config['server']['keepaliveinterval'])
self.timeout = float(self.config['server']['timeout'])
self.flow_info = 0
self.scope_id = 0
self.metrics = []
self.batch_size = int(self.config['server']['batchsize'])
self.max_backlog_multiplier = 4
self.trim_backlog_multiplier = 5
self.namespace = self.config['server']['namespace']
self.maxmetrics = int(self.config['server']['maxmetrics'])
self.runs = int(self.config['server']['runs'])
self.metriccount = 0
# error logging throttling
self.server_error_interval = float(120)
self._errors = {}
self.statsqueue = []
# We do this weird process title swap around to get the sync manager
# title correct for ps
if setproctitle:
oldproctitle = getproctitle()
setproctitle('%s - SyncManager' % getproctitle())
if setproctitle:
setproctitle(oldproctitle)
开发者ID:rsvancara,项目名称:metrichammer,代码行数:42,代码来源:client.py
注:本文中的setproctitle.getproctitle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论