本文整理汇总了Python中socket.getfqdn函数的典型用法代码示例。如果您正苦于以下问题:Python getfqdn函数的具体用法?Python getfqdn怎么用?Python getfqdn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getfqdn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, sa, argv):
import socket
self.sa = sa
self.env = Path(self.sa.env)
self.argv = argv
self.defaults = {
'svn_dir': Path('svn'),
'git_dir': Path('git'),
'trac_dir': Path('trac'),
'http_base': Path('/'),
'http_vhost': socket.getfqdn(),
'trac_url': Path('trac'),
'submin_url': Path('submin'),
'svn_url': Path('svn'),
'create_user': 'yes',
'enable_features': 'svn, git, apache, nginx',
'smtp_from': 'Submin <[email protected]%s>' % socket.getfqdn(),
}
self.init_vars = {
'conf_dir': Path('conf'),
'hooks_dir': Path('hooks'),
}
self.init_vars.update({
'authz': self.init_vars['conf_dir'] + Path('authz'),
'htpasswd': self.init_vars['conf_dir'] + Path('htpasswd'),
})
self.email = None
开发者ID:andy-deng,项目名称:submin,代码行数:27,代码来源:c_initenv.py
示例2: get_user_dns
def get_user_dns():
try:
domain = '.'.join(getfqdn().split('.')[1:])
user_dns = getfqdn(domain).split('.')[0]
except:
user_dns = ''
return user_dns
开发者ID:gnumaniac,项目名称:pulse,代码行数:7,代码来源:sync.py
示例3: check_size
def check_size(file_size, file_name, platform):
""" compare file size with available size on sftpsite """
ssh_key = '/home/encryptonator/.ssh/{}'.format(platform)
df_batch = '/home/encryptonator/df'
if 'ix5' in socket.getfqdn():
squid = 'proxy001.ix5.ops.prod.st.ecg.so'
elif 'esh' in socket.getfqdn():
squid = 'proxy001.esh.ops.prod.st.ecg.so'
with open(df_batch, 'w') as df_file:
df_file.write('df')
df_file.close()
sftp_cmd = "/usr/bin/sftp -b {0} -i {1} -o ProxyCommand='/bin/nc -X connect -x {2}:3128 %h %p' {3}@88.211.136.242".format(df_batch, ssh_key, squid, platform)
proc_sftp = sp.Popen(sftp_cmd, shell=True, stdout=sp.PIPE, stderr=sp.STDOUT)
proc_out = proc_sftp.communicate()[0]
retcode = proc_sftp.returncode
if retcode is not 0:
notify_nagios('Team {} cannot connect to Sftp Site'.format(platform))
return 'noconnection'
else:
proc_out = proc_out.split('\n')[-2] # take last but one row
disk_avail = int(proc_out.split()[-3].replace('%', ''))
if file_size >= disk_avail:
mb_file_size = file_size / 1024
mb_disk_avail = disk_avail / 1024
notify_nagios('The file size to backup ({0} MB) exceeds the space available ({1} MB) on Sftp Site'.format(mb_file_size, mb_disk_avail))
notify_nagios('The file {} will be removed'.format(file_name))
return 'nospace'
开发者ID:maxadamo,项目名称:encryptonator,代码行数:28,代码来源:encryptonator.py
示例4: normalizeURL
def normalizeURL(self, url):
"""
Takes a URL (as returned by absolute_url(), for example) and
replaces the hostname with the actual, fully-qualified
hostname.
"""
url_parts = urlsplit(url)
hostpart = url_parts[1]
port = ''
if hostpart.find(':') != -1:
(hostname, port) = split(hostpart, ':')
else:
hostname = hostpart
if hostname == 'localhost' or hostname == '127.0.0.1':
hostname = getfqdn(gethostname())
else:
hostname = getfqdn(hostname)
if port:
hostpart = join((hostname, port), ':')
url = urlunsplit((url_parts[0], hostpart, \
url_parts[2], url_parts[3], url_parts[4]))
return url
开发者ID:collective,项目名称:ECAssignmentBox,代码行数:26,代码来源:ECABTool.py
示例5: sendPing
def sendPing(self, tasks, isReboot=False):
# Update the values (calls subclass impl)
self.update()
if conf.NETWORK_DISABLED:
return
# Create the hardware profile
hw = ttypes.Hardware()
hw.physicalCpus = self.physicalCpus
hw.logicalCpus = self.logicalCpus
hw.totalRamMb = self.totalRamMb
hw.freeRamMb = self.freeRamMb
hw.totalSwapMb = self.totalSwapMb
hw.freeSwapMb = self.freeSwapMb
hw.cpuModel = self.cpuModel
hw.platform = self.platform
hw.load = self.load
# Create a ping
ping = ttypes.Ping()
ping.hostname = socket.getfqdn()
ping.ipAddr = socket.gethostbyname(socket.getfqdn())
ping.isReboot = isReboot
ping.bootTime = self.bootTime
ping.hw = hw
ping.tasks = tasks
logger.info("Sending ping: %s" % ping)
try:
service, transport = client.getPlowConnection()
service.sendPing(ping)
transport.close()
except Exception, e:
logger.warn("Unable to send ping to plow server, %s" % e)
开发者ID:JohanAberg,项目名称:plow,代码行数:35,代码来源:base.py
示例6: hostInfo
def hostInfo():
hostName = socket.gethostname()
print hostName
print socket.gethostbyname(hostName)
print socket.gethostbyname_ex(hostName)
print socket.getfqdn(hostName)
print socket.getaddrinfo("www.baidu.com", 80)
开发者ID:empljx,项目名称:pyutil,代码行数:7,代码来源:socketUtil.py
示例7: is_me
def is_me(self, lookup_name):
logger.info("And arbiter is launched with the hostname:%s "
"from an arbiter point of view of addr:%s", self.host_name, socket.getfqdn())
if lookup_name:
return lookup_name == self.get_name()
else:
return self.host_name == socket.getfqdn() or self.host_name == socket.gethostname()
开发者ID:andyxning,项目名称:shinken,代码行数:7,代码来源:arbiterlink.py
示例8: _localhosts_aggressive
def _localhosts_aggressive():
answ={}
stack=['localhost', '127.0.0.1', socket.getfqdn(), socket.gethostname()]
def lh_add(*hs):
for h in hs:
if answ.has_key(h):
continue
stack.append(h)
while stack:
h = stack.pop()
if answ.has_key(h):
continue
answ[h] = True
lh_add(socket.getfqdn(h))
try:
lh_add(socket.gethostbyname(h))
except:
pass
try:
fqdn, aliases, ip_addresses = socket.gethostbyname_ex(h)
lh_add(fqdn, *aliases)
lh_add(*ip_addresses)
except:
pass
try:
fqdn, aliases, ip_addresses = socket.gethostbyaddr(h)
lh_add(fqdn, *aliases)
lh_add(*ip_addresses)
except:
pass
return answ
开发者ID:pombredanne,项目名称:beah,代码行数:31,代码来源:__init__.py
示例9: send_problem_report
def send_problem_report(problem):
"""Send a problem report to OCF staff."""
def format_frame(frame):
_, filename, line, funcname, _, _ = frame
return '{}:{} ({})'.format(filename, line, funcname)
callstack = '\n by '.join(map(format_frame, inspect.stack()))
body = \
"""A problem was encountered and reported via ocflib:
{problem}
====
Hostname: {hostname}
Callstack:
at {callstack}
""".format(problem=problem, hostname=socket.getfqdn(), callstack=callstack)
send_mail(
constants.MAIL_ROOT,
'[ocflib] Problem report from ' + socket.getfqdn(),
body,
sender='ocflib <[email protected]>',
)
开发者ID:gnowxilef,项目名称:ocflib,代码行数:25,代码来源:mail.py
示例10: get_hostname
def get_hostname(self):
"""
Returns a hostname as configured by the user
"""
if 'hostname' in self.config:
return self.config['hostname']
if ('hostname_method' not in self.config
or self.config['hostname_method'] == 'fqdn_short'):
return socket.getfqdn().split('.')[0]
if self.config['hostname_method'] == 'fqdn':
return socket.getfqdn().replace('.', '_')
if self.config['hostname_method'] == 'fqdn_rev':
hostname = socket.getfqdn().split('.')
hostname.reverse()
hostname = '.'.join(hostname)
return hostname
if self.config['hostname_method'] == 'uname_short':
return os.uname()[1].split('.')[0]
if self.config['hostname_method'] == 'uname_rev':
hostname = os.uname()[1].split('.')
hostname.reverse()
hostname = '.'.join(hostname)
return hostname
if self.config['hostname_method'].lower() == 'none':
return None
raise NotImplementedError(self.config['hostname_method'])
开发者ID:ciuvo,项目名称:Diamond,代码行数:26,代码来源:collector.py
示例11: __init__
def __init__(self,cp):
global has_gratia
global Gratia
global StorageElement
global StorageElementRecord
if not has_gratia:
try:
Gratia = __import__("Gratia")
StorageElement = __import__("StorageElement")
StorageElementRecord = __import__("StorageElementRecord")
has_gratia = True
except:
raise
if not has_gratia:
print "Unable to import Gratia and Storage modules!"
sys.exit(1)
Gratia.Initialize()
try:
if Gratia.Config.get_SiteName().lower().find('generic') >= 0:
Gratia.Config.setSiteName(socket.getfqdn())
except:
pass
try:
if Gratia.Config.get_ProbeName().lower().find('generic') >= 0:
Gratia.Config.setProbeName('dCache-storage:%s' % socket.getfqdn())
except:
pass
开发者ID:djw8605,项目名称:Gratia,代码行数:28,代码来源:GratiaConnector.py
示例12: submit
def submit(nworker, nserver, fun_submit, hostIP = 'auto', pscmd = None):
if hostIP == 'auto':
hostIP = 'ip'
if hostIP == 'dns':
hostIP = socket.getfqdn()
elif hostIP == 'ip':
hostIP = socket.gethostbyname(socket.getfqdn())
if nserver == 0:
pscmd = None
envs = {'DMLC_NUM_WORKER' : nworker,
'DMLC_NUM_SERVER' : nserver}
rabit = RabitTracker(hostIP = hostIP, nslave = nworker)
pserver = PSTracker(hostIP = hostIP, cmd = pscmd, envs = envs)
envs.update(rabit.slave_envs())
envs.update(pserver.slave_envs())
rabit.start(nworker)
fun_submit(nworker, nserver, envs)
pserver.join()
# start rabit tracker in another thread
if nserver == 0:
rabit.join()
开发者ID:AceMLF,项目名称:dmlc-core,代码行数:26,代码来源:tracker.py
示例13: process
def process(mysettings, key, logentries, fulltext):
if "PORTAGE_ELOG_MAILURI" in mysettings:
myrecipient = mysettings["PORTAGE_ELOG_MAILURI"].split()[0]
else:
myrecipient = "[email protected]"
myfrom = mysettings["PORTAGE_ELOG_MAILFROM"]
myfrom = myfrom.replace("${HOST}", socket.getfqdn())
mysubject = mysettings["PORTAGE_ELOG_MAILSUBJECT"]
mysubject = mysubject.replace("${PACKAGE}", key)
mysubject = mysubject.replace("${HOST}", socket.getfqdn())
# look at the phases listed in our logentries to figure out what action was performed
action = _("merged")
for phase in logentries:
# if we found a *rm phase assume that the package was unmerged
if phase in ["postrm", "prerm"]:
action = _("unmerged")
# if we think that the package was unmerged, make sure there was no unexpected
# phase recorded to avoid misinformation
if action == _("unmerged"):
for phase in logentries:
if phase not in ["postrm", "prerm", "other"]:
action = _("unknown")
mysubject = mysubject.replace("${ACTION}", action)
mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, fulltext)
try:
portage.mail.send_mail(mysettings, mymessage)
except PortageException as e:
writemsg("%s\n" % str(e), noiselevel=-1)
return
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:34,代码来源:mod_mail.py
示例14: find
def find(self, all=False):
'''
If the sll parameter is True, then all methods will be tries and a
list of all RPR's found will be returned.
'''
if self.verbose: print "\tSearching for a BERT-Remote Procedure Repository"
# First try the local machine.
if self.verbose: print "\tTrying the local machine"
if self.search((socket.getfqdn(), self.port)):
if self.verbose: print "\tRPR located: %s:%s" % (socket.getfqdn(), self.port)
if not all: return self.Registries
# First try the supplied places (if any)
if self.verbose and self.places: print "\tTrying supplied places",
elif self.verbose and not self.places: print "\tNo places supplied"
for place in self.places:
if self.verbose: print "\tTrying %s" % (str(place))
if self.search(place):
if self.verbose: print "\tRPR located: %s:%s" % place
if not all: return self.Registries
# Next broadcast for places
if self.verbose: print "\tBroadcasting for an RPR"
for place in self.broadcastForPlaces():
if self.verbose: print "\tResponse from %s:%s" % place
if self.search(place):
if self.verbose: print "\tRPR located: %s:%s" % place
if not all: return self.Registries
if self.verbose: print "\t%s RPR's found" % (len(self.Registries))
return self.Registries
开发者ID:DwayneDibley,项目名称:BERT-RPR,代码行数:32,代码来源:finder.py
示例15: is_me
def is_me(self):
logger.log(
"And arbiter is launched with the hostname:%s from an arbiter point of view of addr :%s"
% (self.host_name, socket.getfqdn()),
print_it=False,
)
return self.host_name == socket.getfqdn() or self.host_name == socket.gethostname()
开发者ID:jfbutkiewicz,项目名称:Windows-Setup-for-Shinken,代码行数:7,代码来源:arbiterlink.py
示例16: _start_services
def _start_services(primary_node, **kwargs):
logger.info("Formatting namenode on %s...", primary_node.fqdn)
primary_node.ssh('hdfs namenode -format')
logger.info("Starting HDFS...")
primary_node.ssh('/hadoop/sbin/start-dfs.sh')
logger.info("Starting YARN...")
primary_node.ssh('/hadoop/sbin/start-yarn.sh')
logger.info('Starting HBase...')
primary_node.ssh('/hbase/bin/start-hbase.sh')
primary_node.ssh('/hbase/bin/hbase-daemon.sh start rest')
logger.info("NameNode and HBase master are located on %s. SSH over and have fun!",
primary_node.hostname)
logger.info("The HDFS NameNode web UI can be reached at http://%s:%s",
getfqdn(), get_host_port_binding(primary_node.container_id,
NAMENODE_WEB_UI_PORT))
logger.info("The YARN ResourceManager web UI can be reached at http://%s:%s",
getfqdn(), get_host_port_binding(primary_node.container_id,
RESOURCEMANAGER_WEB_UI_PORT))
logger.info("The HBase master web UI can be reached at http://%s:%s",
getfqdn(), get_host_port_binding(primary_node.container_id,
kwargs.get('hbase_master_web_ui_port')))
logger.info("The HBase REST server can be reached at http://%s:%s",
getfqdn(), get_host_port_binding(primary_node.container_id,
HBASE_REST_SERVER_PORT))
开发者ID:JingchengDu,项目名称:hbase,代码行数:32,代码来源:actions.py
示例17: main
def main():
module = AnsibleModule(
argument_spec = dict(
name=dict(required=True, type='str')
)
)
hostname = Hostname(module)
changed = False
name = module.params['name']
current_name = hostname.get_current_hostname()
if current_name != name:
hostname.set_current_hostname(name)
changed = True
permanent_name = hostname.get_permanent_hostname()
if permanent_name != name:
hostname.set_permanent_hostname(name)
changed = True
module.exit_json(changed=changed, name=name,
ansible_facts=dict(ansible_hostname=name.split('.')[0],
ansible_nodename=name,
ansible_fqdn=socket.getfqdn(),
ansible_domain='.'.join(socket.getfqdn().split('.')[1:])))
开发者ID:RajeevNambiar,项目名称:temp,代码行数:26,代码来源:hostname.py
示例18: changeToWspaceDir
def changeToWspaceDir():
print '\nTrying to detect and change to your workspace directory...'
getWspaceCmd='accurev show wspaces -f x'
try:
#funny how the absence of the second parameter blanks out e.output in Exception
wspaceResult=subprocess.check_output(getWspaceCmd, stderr=subprocess.STDOUT)
except Exception as e:
print 'Error...'
print e.output
if(re.search(r'Not authenticated', e.output)!=None) or (re.search(r'Expired', e.output)!=None):
print 'Login...'
subprocess.call('accurev login')
wspaceResult=subprocess.check_output(getWspaceCmd)
else:
print 'Quitting'
quit(1)
print wspaceResult
wspaceDir='.'
treeRoot=ET.fromstring(wspaceResult)
for child in treeRoot:
if child.tag.lower() == 'element':
print "child.attrib['Host'].lower()::"+child.attrib['Host'].lower()
print 'socket.getfqdn().lower()::'+socket.getfqdn().lower()
if(re.search(socket.getfqdn().lower(),child.attrib['Host'].lower())!=None) or (re.search(child.attrib['Host'].lower(),socket.getfqdn().lower())!=None): #changed from equals comparison after accurev update (child.attrib['Host'].lower()==socket.getfqdn().lower())
wspaceDir=child.attrib['Storage']
break
print wspaceDir
os.chdir(wspaceDir)
开发者ID:Vyoam,项目名称:accurev-assistant,代码行数:31,代码来源:accurev.py
示例19: submit
def submit(nworker, nserver, fun_submit, hostIP = 'auto', pscmd = None):
if hostIP == 'auto':
hostIP = 'ip'
if hostIP == 'dns':
hostIP = socket.getfqdn()
elif hostIP == 'ip':
from socket import gaierror
try:
hostIP = get_some_ip(socket.getfqdn())
except gaierror:
logging.warn('get_some_ip(socket.getfqdn()) failed... trying on hostname()')
hostIP = get_some_ip(socket.gethostname())
if nserver == 0:
pscmd = None
envs = {'DMLC_NUM_WORKER' : nworker,
'DMLC_NUM_SERVER' : nserver}
rabit = RabitTracker(hostIP = hostIP, nslave = nworker)
pserver = PSTracker(hostIP = hostIP, cmd = pscmd, envs = envs)
envs.update(rabit.slave_envs())
envs.update(pserver.slave_envs())
rabit.start(nworker)
fun_submit(nworker, nserver, envs)
pserver.join()
# start rabit tracker in another thread
if nserver == 0:
rabit.join()
开发者ID:KeeganRen,项目名称:dmlc-core,代码行数:31,代码来源:tracker.py
示例20: main
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True)
),
supports_check_mode=True,
)
hostname = Hostname(module)
name = module.params['name']
current_hostname = hostname.get_current_hostname()
permanent_hostname = hostname.get_permanent_hostname()
changed = hostname.update_current_and_permanent_hostname()
if name != current_hostname:
name_before = current_hostname
elif name != permanent_hostname:
name_before = permanent_hostname
kw = dict(changed=changed, name=name,
ansible_facts=dict(ansible_hostname=name.split('.')[0],
ansible_nodename=name,
ansible_fqdn=socket.getfqdn(),
ansible_domain='.'.join(socket.getfqdn().split('.')[1:])))
if changed:
kw['diff'] = {'after': 'hostname = ' + name + '\n',
'before': 'hostname = ' + name_before + '\n'}
module.exit_json(**kw)
开发者ID:awiddersheim,项目名称:ansible,代码行数:32,代码来源:hostname.py
注:本文中的socket.getfqdn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论