本文整理汇总了Python中progressbar.progressbar方法的典型用法代码示例。如果您正苦于以下问题:Python progressbar.progressbar方法的具体用法?Python progressbar.progressbar怎么用?Python progressbar.progressbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类progressbar
的用法示例。
在下文中一共展示了progressbar.progressbar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CheckPageListAllVulns
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def CheckPageListAllVulns(pageset):
global bar
global currenttested
result = []
bar = progressbar.progressbar("bar", "Search vulns")
bar.totalcount = len(config.vulncheck)
bar.count = 0
for vulnlist in config.vulncheck:
bar.total = len(vulnlist[0])
bar.value = 0
bar.count += 1
currenttested = vulnlist[1]
for vuln in vulnlist[0]:
bar.progress(1)
payload = CheckPageListVuln(pageset, vuln)
if payload:
result.append(payload)
break
bar.delbar()
return result
示例2: _get_annotations
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def _get_annotations(generator):
""" Get the ground truth annotations from the generator.
The result is a list of lists such that the size is:
all_detections[num_images][num_classes] = annotations[num_detections, 5]
# Arguments
generator : The generator used to retrieve ground truth annotations.
# Returns
A list of lists containing the annotations for each image in the generator.
"""
all_annotations = [[None for i in range(generator.num_classes())] for j in range(generator.size())]
for i in progressbar.progressbar(range(generator.size()), prefix='Parsing annotations: '):
# load the annotations
annotations = generator.load_annotations(i)
# copy detections to all_annotations
for label in range(generator.num_classes()):
if not generator.has_label(label):
continue
all_annotations[i][label] = annotations['bboxes'][annotations['labels'] == label, :].copy()
return all_annotations
示例3: build_node_index
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def build_node_index(fname):
node_index = {}
with open(fname, 'rb') as f:
f.seek(0, 2)
bytes = f.tell()
f.seek(0, 0)
with progressbar.ProgressBar(max_value=bytes) as bar:
end_of_line = 0
for l in f:
parts = l.decode('utf8').split(' ')
pip, node = parts[0:2]
if node not in node_index:
node_index[node] = []
node_index[node].append(end_of_line)
end_of_line = f.tell()
bar.update(end_of_line)
return node_index
示例4: generate_tileconn
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def generate_tileconn(pool, node_tree, nodes, wire_map, grid):
tileconn = []
key_history = {}
raw_node_data = []
with progressbar.ProgressBar(max_value=len(nodes)) as bar:
for idx, node in enumerate(pool.imap_unordered(
read_json5,
nodes,
chunksize=20,
)):
bar.update(idx)
raw_node_data.append(node)
process_node(
tileconn, key_history, node, wire_map, node_tree, grid)
bar.update(idx + 1)
tileconn = flatten_tile_conn(tileconn)
return tileconn, raw_node_data
示例5: generate_results
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def generate_results(yolov3, imgs_dir, jpgs, results_file, non_coco):
"""Run detection on each jpg and write results to file."""
results = []
for jpg in progressbar(jpgs):
img = cv2.imread(os.path.join(imgs_dir, jpg))
image_id = int(jpg.split('.')[0].split('_')[-1])
boxes, confs, clss = yolov3.detect(img, conf_th=1e-2)
for box, conf, cls in zip(boxes, confs, clss):
x = float(box[0])
y = float(box[1])
w = float(box[2] - box[0] + 1)
h = float(box[3] - box[1] + 1)
cls = cls if non_coco else yolov3_cls_to_ssd[cls]
results.append({'image_id': image_id,
'category_id': cls,
'bbox': [x, y, w, h],
'score': float(conf)})
with open(results_file, 'w') as f:
f.write(json.dumps(results, indent=4))
示例6: generate_results
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def generate_results(ssd, imgs_dir, jpgs, results_file):
"""Run detection on each jpg and write results to file."""
results = []
for jpg in progressbar(jpgs):
img = cv2.imread(os.path.join(imgs_dir, jpg))
image_id = int(jpg.split('.')[0].split('_')[-1])
boxes, confs, clss = ssd.detect(img, conf_th=1e-2)
for box, conf, cls in zip(boxes, confs, clss):
x = float(box[0])
y = float(box[1])
w = float(box[2] - box[0] + 1)
h = float(box[3] - box[1] + 1)
results.append({'image_id': image_id,
'category_id': int(cls),
'bbox': [x, y, w, h],
'score': float(conf)})
with open(results_file, 'w') as f:
f.write(json.dumps(results, indent=4))
示例7: processPlaintext
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def processPlaintext(self, stream: PacketList, outfile: str, info):
"""Process a plaintext EXPORTED PDU RDP export to a replay."""
replayer = RDPReplayer(outfile, mp4=self.args.format == 'mp4')
(client, server, _, _) = info
for packet in progressbar.progressbar(stream):
src = ".".join(str(b) for b in packet.load[12:16])
dst = ".".join(str(b) for b in packet.load[20:24])
data = packet.load[60:]
if src not in [client, server] or dst not in [client, server]:
continue
# FIXME: The absolute time is completely wrong here because replayer multiplies by 1000.
replayer.setTimeStamp(float(packet.time))
replayer.recv(data, src == client)
try:
replayer.tcp.recordConnectionClose()
except struct.error:
print("Couldn't close the connection cleanly. "
"Are you sure you got source and destination correct?")
示例8: processReplay
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def processReplay(self, infile: Path):
widgets = [
progressbar.FormatLabel('Encoding MP4 '),
progressbar.BouncingBar(),
progressbar.FormatLabel(' Elapsed: %(elapsed)s'),
]
with progressbar.ProgressBar(widgets=widgets) as progress:
print(f"[*] Converting '{infile}' to MP4.")
outfile = self.prefix + infile.stem + '.mp4'
sink = Mp4EventHandler(outfile, progress=lambda: progress.update(0))
fd = open(infile, "rb")
replay = Replay(fd, handler=sink)
print(f"\n[+] Succesfully wrote '{outfile}'")
sink.cleanup()
fd.close()
示例9: evaluate
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def evaluate(self):
for ds in progressbar.progressbar(self.datasets):
(X_train, y_train, X_test, y_test) = ds.data()
for det in progressbar.progressbar(self.detectors):
self.logger.info(f'Training {det.name} on {ds.name} with seed {self.seed}')
try:
det.fit(X_train.copy())
score = det.predict(X_test.copy())
self.results[(ds.name, det.name)] = score
try:
self.plot_details(det, ds, score)
except Exception:
pass
except Exception as e:
self.logger.error(f'An exception occurred while training {det.name} on {ds}: {e}')
self.logger.error(traceback.format_exc())
self.results[(ds.name, det.name)] = np.zeros_like(y_test)
gc.collect()
示例10: _get_annotations
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def _get_annotations(generator):
""" Get the ground truth annotations from the generator.
The result is a list of lists such that the size is:
all_detections[num_images][num_classes] = annotations[num_detections, 5]
# Arguments
generator : The generator used to retrieve ground truth annotations.
# Returns
A list of lists containing the annotations for each image in the generator.
"""
all_annotations = [[None for i in range(generator.num_classes())] for j in range(generator.size())]
for i in progressbar.progressbar(range(generator.size()), prefix='Parsing annotations: '):
# load the annotations
annotations = generator.load_annotations(i)
# copy detections to all_annotations
for label in range(generator.num_classes()):
if not generator.has_label(label):
continue
all_annotations[i][label] = annotations['bboxes'][annotations['labels'] == label, :].copy()
return all_annotations
示例11: GetAllPages
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def GetAllPages(urllist):
links = {None:None}
templinks = {None}
linksfollowed = {None}
newlinks = {None}
for url in urllist:
html = GetHTML(url)
links.update({url:html})
templinks.update(GetLinks(url, html))
templinks.update(GetAllURLsParams(url))
linksfollowed.update(url)
newlinks.update(url)
links.pop(None)
templinks.remove(None)
linksfollowed.remove(None)
newlinks.remove(None)
bar = progressbar.progressbar("count", "Get URLs")
while templinks:
bar.progress(len(templinks))
for link in templinks:
html = GetHTML(link)
links.update({link:html})
newlinks.update(GetLinks(link, html))
newlinks.update(GetAllURLsParams(link))
linksfollowed.update({link})
templinks = newlinks.difference(linksfollowed)
bar.delbar()
result = {}
for link in links:
if not CheckBlackListURLs(link):
result.update({link:links[link]})
return result
示例12: get_submissions_status
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def get_submissions_status():
"""
:return: A list of statuses of all the submissions in the database
"""
results = []
database = Database()
print("Fetching analysis statuses...Please wait.")
for row in progressbar.progressbar(Database().select_pcaps()):
_id, name, capture_start, capture_end, upload_start, upload_end, size = row
try:
raw_result = next(database.select_completed(_id))
res = json.loads(raw_result[1])
except StopIteration:
res = PTClient().get_pcap_status(_id)
if res and res.get('analysisCompleted'):
try:
database.insert_completed([_id, json.dumps(res)])
except Exception as e:
logger.warning('Could not cache status for {} - {}'.format(_id, e))
queued, analysis_started, analysis_completed = False, False, False
link = None
malicious = None
if res:
submission = res.get('submission', {})
if submission.get('queuedTimestamp'):
queued = True
if submission.get('analysisStarted'):
analysis_started = True
if submission.get('analysisCompleted'):
analysis_completed = True
if 'signature_alerts' in submission.get('logsTransmitted'):
malicious = True
else:
malicious = False
if analysis_completed:
link = "https://packettotal.com/app/analysis?id={}".format(_id)
results.append([_id, name, capture_start, capture_end, upload_start, upload_end, size, queued, analysis_started,
analysis_completed, malicious, link])
return results
示例13: learn
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def learn(self, timeout=60):
"""
Builds a whitelist of IP addresses for every connection captured during this time-period
:param timeout: The number of seconds to capture traffic
"""
src_ips = set()
dst_ips = set()
with open('ip.whitelist', 'w') as f:
if not sys.warnoptions:
warnings.simplefilter("ignore")
print('Generating whitelist of IP addresses based on traffic from the next {} seconds.'.format(timeout))
bar = progressbar.ProgressBar(max_value=progressbar.UnknownLength)
for conn in self.listener(timeout=timeout):
try:
src, dst, proto = conn
if IP(src).iptype() == 'PUBLIC':
src_ips.add(src)
bar.update(len(src_ips) + len(dst_ips))
if IP(dst).iptype() == 'PUBLIC':
dst_ips.add(dst)
bar.update(len(src_ips) + len(dst_ips))
except AttributeError:
pass
all_ips = list(src_ips)
all_ips.extend(dst_ips)
all_ips = set(all_ips)
for ip in all_ips:
f.write(ip + '\n')
示例14: generate_tilegrid
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def generate_tilegrid(pool, tiles):
wire_map = {}
grid = {}
num_tiles = 0
for tile_type in tiles:
num_tiles += len(tiles[tile_type])
idx = 0
with progressbar.ProgressBar(max_value=num_tiles) as bar:
for tile_type in tiles:
for tile in pool.imap_unordered(
get_tile_grid_info,
tiles[tile_type],
chunksize=20,
):
bar.update(idx)
assert len(tile) == 1, tile
tilename = tuple(tile.keys())[0]
for wire in tile[tilename]['wires']:
assert wire not in wire_map, (wire, wire_map)
assert wire.startswith(tilename + '/'), (wire, tilename)
wire_map[wire] = {
'tile': tilename,
'type': tile[tilename]['type'],
'shortname': wire[len(tilename) + 1:],
}
del tile[tilename]['wires']
grid.update(tile)
idx += 1
bar.update(idx)
return grid, wire_map
示例15: load_from_root_csv
# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import progressbar [as 别名]
def load_from_root_csv(self, nodes):
import pyjson5 as json5
import progressbar
for node in progressbar.progressbar(nodes):
with open(node) as f:
node_wires = json5.load(f)
assert node_wires['node'] not in self.nodes
self.nodes[node_wires['node']] = node_wires['wires']