text stringlengths 0 828 |
|---|
print(' * Serving Flask app ""%s""' % info.app_import_path) |
if debug is not None: |
print(' * Forcing debug mode %s' % (debug and 'on' or 'off')) |
reloader_path = '.' |
if info.app_import_path: |
if os.path.isdir(info.app_import_path): |
reloader_path = info.app_import_path |
elif os.path.isfile(info.app_import_path): |
reloader_path = os.path.dirname(info.app_import_path) |
extra_files = get_reloader_extra_files(reloader_path) |
run_simple(host, port, app, use_reloader=reload, extra_files=extra_files, |
use_debugger=debugger, threaded=with_threads)" |
1200,"def load_calls(self, call_type='jsonrpc'): |
""""""Loads the KvasirAPI calls into API.call based on the call_type variable. Utilizes the `Calls` class to |
establish an attribute-based access method. For instance a configuration with an instance called 'internal' |
will create an API.call that can be used like this: |
API.call.internal.hosts.list() # return all hosts from Kvasir instance 'internal' |
:param call_type: string of 'jsonrpc' or 'restapi' |
:return: self.call dictionary |
"""""" |
valid = False |
if call_type == 'jsonrpc': |
#from jsonrpc import Hosts, Services, Accounts, Vulns, OS, NetBIOS, Evidence |
import jsonrpc as api_calls |
self.api_calls = api_calls |
valid = True |
#if call_type == 'rest' |
# TODO: Implement restful API functions |
#from restapi import hosts, services, accounts, vulns, os, netbios, evidence |
if valid: |
# if kvasir configuration is valid, go through the instances and build the self.call dict |
for instance, values in self.configuration.instances_dict.items(): |
self.call[instance] = Calls() |
self.call[instance].call_type = call_type |
self.call[instance].hosts = self.api_calls.Hosts(values, self.configuration.web2py_dir) |
self.call[instance].services = self.api_calls.Services(values, self.configuration.web2py_dir) |
self.call[instance].accounts = self.api_calls.Accounts(values, self.configuration.web2py_dir) |
self.call[instance].vulns = self.api_calls.Vulns(values, self.configuration.web2py_dir) |
self.call[instance].os = self.api_calls.OpSys(values, self.configuration.web2py_dir) |
self.call[instance].snmp = self.api_calls.SNMP(values, self.configuration.web2py_dir) |
self.call[instance].netbios = self.api_calls.NetBIOS(values, self.configuration.web2py_dir) |
self.call[instance].evidence = self.api_calls.Evidence(values, self.configuration.web2py_dir) |
self.call[instance].stats = self.api_calls.Stats(values, self.configuration.web2py_dir)" |
1201,"def install_brew(target_path): |
"""""" Install brew to the target path """""" |
if not os.path.exists(target_path): |
try: |
os.makedirs(target_path) |
except OSError: |
logger.warn(""Unable to create directory %s for brew."" % target_path) |
logger.warn(""Skipping..."") |
return |
extract_targz(HOMEBREW_URL, target_path, remove_common_prefix=True)" |
1202,"def scales(self, image): |
""""""scales(image) -> scale, shape |
Computes the all possible scales for the given image and yields a tuple of the scale and the scaled image shape as an iterator. |
**Parameters::** |
``image`` : array_like(2D or 3D) |
The image, for which the scales should be computed |
**Yields:** |
``scale`` : float |
The next scale of the image to be considered |
``shape`` : (int, int) or (int, int, int) |
The shape of the image, when scaled with the current ``scale`` |
"""""" |
# compute the minimum scale so that the patch size still fits into the given image |
minimum_scale = max(self.m_patch_box.size_f[0] / image.shape[-2], self.m_patch_box.size_f[1] / image.shape[-1]) |
if self.m_lowest_scale: |
maximum_scale = min(minimum_scale / self.m_lowest_scale, 1.) |
else: |
maximum_scale = 1. |
current_scale_power = 0. |
# iterate over all possible scales |
while True: |
# scale the image |
scale = minimum_scale * math.pow(self.m_scale_factor, current_scale_power) |
if scale > maximum_scale: |
# image is smaller than the requested minimum size |
break |
current_scale_power -= 1. |
scaled_image_shape = bob.ip.base.scaled_output_shape(image, scale) |
# return both the scale and the scaled image size |
yield scale, scaled_image_shape" |
1203,"def sample_scaled(self, shape): |
""""""sample_scaled(shape) -> bounding_box |
Yields an iterator that iterates over all sampled bounding boxes in the given (scaled) image shape. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.