本文整理汇总了Python中scan.scan方法的典型用法代码示例。如果您正苦于以下问题:Python scan.scan方法的具体用法?Python scan.scan怎么用?Python scan.scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scan
的用法示例。
在下文中一共展示了scan.scan方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def run(self):
while True:
try:
task_host = self.queue.get(block=False)
except:
break
try:
if self.mode:
port_list = AC_PORT_LIST[task_host]
else:
port_list = self.config_ini['Port_list'].split('|')[1].split('\n')
_s = scan.scan(task_host, port_list)
_s.config_ini = self.config_ini # ??????
_s.statistics = self.statistics # ??????
_s.run()
except Exception, e:
print e
finally:
self.queue.task_done()
示例2: run
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def run(self):
while True:
if self.queue.empty(): break
try:
task_host = self.queue.get()
if self.mode:
port_list = AC_PORT_LIST[task_host]
else:
port_list = self.config_ini['Port_list'].split('|')[1].split('\n')
_s = scan.scan(task_host, port_list)
_s.config_ini = self.config_ini # ??????
_s.statistics = self.statistics # ??????
_s.run()
except Exception,e:
print e
finally:
self.queue.task_done()
示例3: copyScans
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def copyScans(self, ids=[], pos=None, calCheck=True):
# Copy the scans specified by their IDs and put the copies beginning at
# the nominated position (or at the end by default).
if len(ids) == 0:
return None
# Try to find the scans.
j = 0
for i in xrange(0, len(ids)):
cscan = self.getScanById(ids[i])
if cscan is not None:
copts = self.scanToOptions(cscan)
copts['nocopy'] = True
if pos is not None and pos >= 0 and pos < len(self.scans):
copts['insertIndex'] = pos + j
nscan = self.addScan(copts)
# Set its ID.
nscan.setId(cscan.getId())
# We do this because j only increments when a scan is found.
j += 1
if calCheck == True:
# Now run the calibrator assignment checks.
self.checkCalibrators()
示例4: enableAutoCalibrators
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def enableAutoCalibrators(self):
# Enable the calibrator scan checking function.
self.autoCals = True
return self
示例5: disableAutoCalibrators
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def disableAutoCalibrators(self):
# Disable the calibrator scan checking function.
self.autoCals = False
return self
示例6: addScan
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def addScan(self, options={}):
# Add a scan to the schedule.
scan_new = scan()
# By default, we copy the details from the previous scan.
if (not ('nocopy' in options and options['nocopy'] == True)) and (len(self.scans) > 0):
scan_old = self.scans[-1]
for f in self.__scanHandlers:
# We don't copy the CalCode.
if (f != "CalCode"):
getattr(scan_new, self.__scanHandlers[f]['set'])(getattr(scan_old, self.__scanHandlers[f]['get'])())
for f in self.__freqHandlers:
getattr(getattr(scan_new, self.__freqHandlers[f]['object'])(), self.__freqHandlers[f]['set'])(
getattr(getattr(scan_old, self.__freqHandlers[f]['object'])(), self.__freqHandlers[f]['get'])())
# Check for options for the scan.
for f in self.__scanHandlers:
if self.__scanHandlers[f]['option'] in options:
val = self.__prepareValue(options[self.__scanHandlers[f]['option']], self.__scanHandlers[f]['format'])
getattr(scan_new, self.__scanHandlers[f]['set'])(val)
for f in self.__freqHandlers:
if self.__freqHandlers[f]['option'] in options:
val = self.__prepareValue(options[self.__freqHandlers[f]['option']], self.__freqHandlers[f]['format'])
getattr(getattr(scan_new, self.__freqHandlers[f]['object'])(), self.__freqHandlers[f]['set'])(val)
# Add the scan to the list.
if ('insertIndex' in options and options['insertIndex'] >= 0):
# We have been asked to insert the scan at a particular position.
# Check if the insertIndex is too large.
if (options['insertIndex'] >= len(self.scans)):
self.scans.append(scan_new)
else:
self.scans.insert(options['insertIndex'], scan_new)
else:
self.scans.append(scan_new)
return scan_new
示例7: deleteScan
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def deleteScan(self, idx=None):
# Delete a scan from the schedule, using the Python del indexing standard.
if idx is not None:
del self.scans[idx]
示例8: getScanById
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def getScanById(self, id=None):
# Return the scan specified.
if id is not None:
for i in xrange(0, len(self.scans)):
if self.scans[i].getId() == id:
return self.scans[i]
return None
示例9: scanToOptions
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def scanToOptions(self, scan=None):
# Turn a scan into an options object.
oopts = {}
if scan is not None:
for f in self.__scanHandlers:
oopts[self.__scanHandlers[f]['option']] = getattr(scan, self.__scanHandlers[f]['get'])()
for f in self.__freqHandlers:
oopts[self.__freqHandlers[f]['option']] = getattr(getattr(scan, self.__freqHandlers[f]['object'])(), self.__freqHandlers[f]['get'])()
return oopts
示例10: toString
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def toString(self):
# Make the schedule into a string.
# Check we have all our calibrator scans.
self.checkCalibrators()
outputStrings = []
for i in xrange(0, len(self.scans)):
# Every scan starts the same way.
outputStrings.append("$SCAN*V5")
for h in self.__scanHandlers:
outf = h + "=" + self.__formatSpecifier(self.__scanHandlers[h]['format'])
prevScan = None
if i > 0:
prevScan = self.scans[i - 1]
nString = self.__prepareScheduleLine(self.scans[i], prevScan,
self.__scanHandlers[h]['get'], outf)
if nString is not None:
outputStrings.append(nString)
for h in self.__freqHandlers:
outf = h + "=" + self.__formatSpecifier(self.__freqHandlers[h]['format'])
prevScan = None
if i > 0:
prevScan = getattr(self.scans[i - 1], self.__freqHandlers[h]['object'])()
nString = self.__prepareScheduleLine(getattr(self.scans[i], self.__freqHandlers[h]['object'])(),
prevScan, self.__freqHandlers[h]['get'], outf)
if nString is not None:
outputStrings.append(nString)
# And every scan ends the same way.
outputStrings.append("$SCANEND")
# Make the output string by joining the elements with the newline character.
return "\n".join(outputStrings) + "\n"
示例11: addCalibrator
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def addCalibrator(self, calibrator=None, refScan=None, options={}):
# Add a calibrator database calibrator to the schedule.
if calibrator is None or refScan is None:
return None
# We attach the calibrator to the source scans that match the details
# passed in as the refScan. So we first find which scans match.
# We match only on source name, position and frequency configuration.
matchedScans = []
for i in xrange(0, len(self.scans)):
if (self.scans[i].getSource() == refScan.getSource() and
self.scans[i].getRightAscension() == refScan.getRightAscension() and
self.scans[i].getDeclination() == refScan.getDeclination() and
self.scans[i].IF1().getFreq() == refScan.IF1().getFreq() and
self.scans[i].IF2().getFreq() == refScan.IF2().getFreq()):
matchedScans.append(i)
# Ensure the ID of each of the matched scans is the same.
self.scans[i].setId(refScan.getId())
# Craft the calibrator scan.
noptions = options
noptions['source'] = calibrator.getName()
noptions['rightAscension'] = calibrator.getRightAscension()
noptions['declination'] = calibrator.getDeclination()
noptions['freq1'] = refScan.IF1().getFreq()
noptions['freq2'] = refScan.IF2().getFreq()
noptions['calCode'] = "C"
# We place the calibrator scan before each of the matched scans.
# Or afterwards if we don't want to get to the calibrator first.
nscan = None
for i in xrange(0, len(matchedScans)):
# Remember, the index of the matched scan will go up by one every time
# we put a new scan in before it.
ni = i + matchedScans[i]
noptions['insertIndex'] = ni
if self.calFirst == False:
noptions['insertIndex'] = ni + 1
nscan = self.addScan(noptions)
if i == 0:
# Associate the calibrator to the scan.
self.calibratorAssociations[refScan.getId()] = nscan.getId()
else:
# Put the same ID on all the calibrators.
nscan.setId(self.calibratorAssociations[refScan.getId()])
return nscan
示例12: checkCalibrators
# 需要导入模块: import scan [as 别名]
# 或者: from scan import scan [as 别名]
def checkCalibrators(self):
# Check that a calibrator scan is assigned to each of the associated
# sources, and add a scan if it isn't.
if self.autoCals == False:
# The user doesn't want us to do this.
return
i = 0
while (i < len(self.scans)):
# We loop like this because the length of the array may change as
# we go through.
tId = self.scans[i].getId()
# Check if this is a source with an associated calibrator.
if tId in self.calibratorAssociations:
# It is. Check if there is a calibrator scan before it.
if self.calFirst == True:
if i == 0:
# Nope, first scan, we add a calibrator scan.
self.copyScans([ self.calibratorAssociations[tId] ], 0, False)
else:
pId = self.scans[i - 1].getId()
if pId != self.calibratorAssociations[tId]:
# Nope, the scan before this one is not the calibrator.
self.copyScans([ self.calibratorAssociations[tId] ], i, False)
# Otherwise it is the calibrator scan.
# Check if there needs to be a calibrator scan after it.
if i == (len(self.scans) - 1):
# We're at the end of the list.
if self.looping == False or self.calFirst == False:
# We do need a cal scan at the end, because it won't go around, or when
# it does there won't be a calibrator there.
self.copyScans([ self.calibratorAssociations[tId] ], (i + 1), False)
else:
# Check that the first scan is a calibrator scan.
pId = self.scans[0].getId()
if pId != self.calibratorAssociations[tId]:
# The first scan is not a calibrator scan, so we add one here.
self.copyScans([ self.calibratorAssociations[tId] ], (i + 1), False)
# Otherwise, it will loop back around to the calibrator.
else:
# Check the ID of the next scan.
nId = self.scans[i + 1].getId()
if nId != self.calibratorAssociations[tId] and nId != tId:
# There is another scan after us, but it isn't the same as us, and
# it isn't our calibrator. We add a cal scan.
self.copyScans([ self.calibratorAssociations[tId] ], (i + 1), False)
i += 1
return