本文整理汇总了Python中pxStats.lib.StatsPaths.StatsPaths.getPXPathFromMachine方法的典型用法代码示例。如果您正苦于以下问题:Python StatsPaths.getPXPathFromMachine方法的具体用法?Python StatsPaths.getPXPathFromMachine怎么用?Python StatsPaths.getPXPathFromMachine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxStats.lib.StatsPaths.StatsPaths
的用法示例。
在下文中一共展示了StatsPaths.getPXPathFromMachine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transferLogFiles
# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import getPXPathFromMachine [as 别名]
def transferLogFiles():
"""
@summary : Log files will not be tansferred if local machine
is not designed to be a pickling machine.
If log files are to be transferred, they will be straight
from the source."
"""
paths = StatsPaths()
paths.setPaths()
parameters = StatsConfigParameters()
machineParameters = MachineConfigParameters()
machineParameters.getParametersFromMachineConfigurationFile()
parameters.getAllParameters()
individualSourceMachines = machineParameters.getMachinesAssociatedWithListOfTags( parameters.sourceMachinesTags )
individualPicklingMachines = machineParameters.getMachinesAssociatedWithListOfTags( parameters.picklingMachines )
for sourceMachine,picklingMachine in map( None, individualSourceMachines, individualPicklingMachines ) :
if picklingMachine == LOCAL_MACHINE :#pickling to be done here
userName = machineParameters.getUserNameForMachine(sourceMachine)
remoteLogPath = paths.getPXPathFromMachine( paths.PXLOG, sourceMachine, userName )
print "rsync -avzr --delete-before -e ssh %[email protected]%s:%s %s%s/ " %( userName , sourceMachine,remoteLogPath , paths.STATSLOGS, sourceMachine )
output = commands.getoutput( "rsync -avzr --delete-before -e ssh %[email protected]%s:%s %s%s/ " %( userName , sourceMachine, remoteLogPath, paths.STATSLOGS, sourceMachine ) )
print output
示例2: updatePickles
# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import getPXPathFromMachine [as 别名]
def updatePickles( parameters, machineParameters, currentTimeInIsoFormat ):
"""
@summary : Updates the pickle files for all the specified log machines
so that they are available for graphic production.
@note : Pickling is to be done on specified pickling machines.
All the pickle files that are produced on remote machines will be
downloaded on the local machine.
@param parameters: StatsConfigParameters instance containing
the parameters found in the config file.
@param machineParameters: MachineConfigParameters instance containing
the parameters found in the config file.
@param currentTimeInIsoFormat : Time at which this program was originally
called.
"""
nbChildProcess = 0
paths = StatsPaths()
paths.setPaths()
for tag in parameters.sourceMachinesTags:
pid = os.fork()
if pid == 0: #if child
sourceMachines = machineParameters.getMachinesAssociatedWith(tag)
for i in range( len( sourceMachines ) ):
picklingMachine = parameters.detailedParameters.picklingMachines[tag][i]
# If pickling and source machines differ, download log files frm source to pickling machine.
if sourceMachines[i] != picklingMachine:
if parameters.detailedParameters.picklingMachines[tag][i] != LOCAL_MACHINE :#pickling to be done elsewhere
for j in range(3):#do 3 times in case of currently turning log files.
remotePxLogPath = paths.getPXPathFromMachine(paths.PXLOG, sourceMachines[i], machineParameters.getUserNameForMachine( sourceMachines[i]))
output = commands.getoutput( "ssh %[email protected]%s 'rsync -avzr --delete-before -e ssh %[email protected]%s:%s %s%s/' " %( machineParameters.getUserNameForMachine( picklingMachine), picklingMachine,machineParameters.getUserNameForMachine( sourceMachines[i] ) , sourceMachines[i] , remotePxLogPath, paths.STATSLOGS, sourceMachines[i] ) )
print "ssh %[email protected]%s 'rsync -avzr --delete-before -e ssh %[email protected]%s:%s %s%s/' " %( machineParameters.getUserNameForMachine( picklingMachine), picklingMachine,machineParameters.getUserNameForMachine( sourceMachines[i] ) , sourceMachines[i] , remotePxLogPath, paths.STATSLOGS, sourceMachines[i] )
print output
else:
for j in range(3):#do 3 times in case of currently turning log files.
remotePxLogPath = paths.getPXPathFromMachine(paths.PXLOG, sourceMachines[i], machineParameters.getUserNameForMachine( sourceMachines[i]))
print "le remote paths : ", remotePxLogPath
print
output = commands.getoutput( "rsync -avzr --delete-before -e ssh %[email protected]%s:%s %s%s/ " %( machineParameters.getUserNameForMachine( sourceMachines[i] ), sourceMachines[i] , remotePxLogPath, paths.STATSLOGS, sourceMachines[i] ) )
print
print "*****************************"
print
print "rsync -avzr --delete-before -e ssh " + """%[email protected]%s:%s %s%s/""" %( machineParameters.getUserNameForMachine( sourceMachines[i] ), sourceMachines[i] , remotePxLogPath, paths.STATSLOGS, sourceMachines[i] )
print
print output
if picklingMachine != LOCAL_MACHINE :#pickling to be done elsewhere,needs ssh
output = commands.getoutput( """ssh %[email protected]%s 'python %spickleUpdater.py -m %s -f rx --date "%s" ' """ %( machineParameters.getUserNameForMachine( picklingMachine ), picklingMachine, paths.STATSBIN, sourceMachines[i], currentTimeInIsoFormat ) )
print "ssh %[email protected]%s 'python %spickleUpdater.py -m %s -f rx' " %( machineParameters.getUserNameForMachine( picklingMachine ), picklingMachine, paths.STATSBIN, sourceMachines[i] )
print output
output = commands.getoutput( """ssh %[email protected]%s 'python %spickleUpdater.py -m %s -f tx --date "%s" ' """( machineParameters.getUserNameForMachine( picklingMachine ), picklingMachine , paths.STATSBIN, sourceMachines[i], currentTimeInIsoFormat ) )
print "ssh %[email protected]%s 'python %spickleUpdater.py -m %s -f tx' "%( machineParameters.getUserNameForMachine( picklingMachine ), picklingMachine , paths.STATSBIN, sourceMachines[i] )
print output
output = commands.getoutput( """%spickleSynchroniser.py -l %s -m %s """%( paths.STATSTOOLS, machineParameters.getUserNameForMachine( picklingMachine ), picklingMachine ) )
print "%spickleSynchroniser.py -l %s -m %s " %( paths.STATSTOOLS, machineParameters.getUserNameForMachine( picklingMachine ), picklingMachine )
print output
else: # pickling is to be done locally. Log files may or may not reside elsewhere.
output = commands.getoutput( """python %spickleUpdater.py -f rx -m %s --date "%s" """%( paths.STATSBIN, sourceMachines[i], currentTimeInIsoFormat ) )
print "python %spickleUpdater.py -f rx -m %s " %( paths.STATSBIN, sourceMachines[i] )
print output
output = commands.getoutput( """python %spickleUpdater.py -f tx -m %s --date "%s" """ %( paths.STATSBIN, sourceMachines[i], currentTimeInIsoFormat ) )
print "python %spickleUpdater.py -f tx -m %s " %( paths.STATSBIN, sourceMachines[i] )
print output
sys.exit()
elif nbChildProcess!=0 and nbChildProcess%3 == 0 :
while True:#wait on all non terminated child process'
try: #will raise exception when no child process remain.
pid, status = os.wait()
except:
break
while True:#wait on all non terminated child process'
try: #will raise exception when no child process remain.
pid, status = os.wait( )
except:
break