repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.all_sample_md5s
def all_sample_md5s(self, type_tag=None): """Return a list of all md5 matching the type_tag ('exe','pdf', etc). Args: type_tag: the type of sample. Returns: a list of matching samples. """ if type_tag: cursor = self.database[self.sample_coll...
python
def all_sample_md5s(self, type_tag=None): """Return a list of all md5 matching the type_tag ('exe','pdf', etc). Args: type_tag: the type of sample. Returns: a list of matching samples. """ if type_tag: cursor = self.database[self.sample_coll...
[ "def", "all_sample_md5s", "(", "self", ",", "type_tag", "=", "None", ")", ":", "if", "type_tag", ":", "cursor", "=", "self", ".", "database", "[", "self", ".", "sample_collection", "]", ".", "find", "(", "{", "'type_tag'", ":", "type_tag", "}", ",", "{...
Return a list of all md5 matching the type_tag ('exe','pdf', etc). Args: type_tag: the type of sample. Returns: a list of matching samples.
[ "Return", "a", "list", "of", "all", "md5", "matching", "the", "type_tag", "(", "exe", "pdf", "etc", ")", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L370-L384
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.clear_worker_output
def clear_worker_output(self): """Drops all of the worker output collections""" print 'Dropping all of the worker output collections... Whee!' # Get all the collections in the workbench database all_c = self.database.collection_names() # Remove collections that we don't...
python
def clear_worker_output(self): """Drops all of the worker output collections""" print 'Dropping all of the worker output collections... Whee!' # Get all the collections in the workbench database all_c = self.database.collection_names() # Remove collections that we don't...
[ "def", "clear_worker_output", "(", "self", ")", ":", "print", "'Dropping all of the worker output collections... Whee!'", "# Get all the collections in the workbench database", "all_c", "=", "self", ".", "database", ".", "collection_names", "(", ")", "# Remove collections that we...
Drops all of the worker output collections
[ "Drops", "all", "of", "the", "worker", "output", "collections" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L386-L405
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.periodic_ops
def periodic_ops(self): """Run periodic operations on the the data store. Operations like making sure collections are capped and indexes are set up. """ # Only run every 30 seconds if (time.time() - self.last_ops_run) < 30: return try: ...
python
def periodic_ops(self): """Run periodic operations on the the data store. Operations like making sure collections are capped and indexes are set up. """ # Only run every 30 seconds if (time.time() - self.last_ops_run) < 30: return try: ...
[ "def", "periodic_ops", "(", "self", ")", ":", "# Only run every 30 seconds", "if", "(", "time", ".", "time", "(", ")", "-", "self", ".", "last_ops_run", ")", "<", "30", ":", "return", "try", ":", "# Reset last ops run", "self", ".", "last_ops_run", "=", "t...
Run periodic operations on the the data store. Operations like making sure collections are capped and indexes are set up.
[ "Run", "periodic", "operations", "on", "the", "the", "data", "store", ".", "Operations", "like", "making", "sure", "collections", "are", "capped", "and", "indexes", "are", "set", "up", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L413-L468
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.to_unicode
def to_unicode(self, s): """Convert an elementary datatype to unicode. Args: s: the datatype to be unicoded. Returns: Unicoded data. """ # Fixme: This is total horseshit if isinstance(s, unicode): return s if isinstance(s, st...
python
def to_unicode(self, s): """Convert an elementary datatype to unicode. Args: s: the datatype to be unicoded. Returns: Unicoded data. """ # Fixme: This is total horseshit if isinstance(s, unicode): return s if isinstance(s, st...
[ "def", "to_unicode", "(", "self", ",", "s", ")", ":", "# Fixme: This is total horseshit", "if", "isinstance", "(", "s", ",", "unicode", ")", ":", "return", "s", "if", "isinstance", "(", "s", ",", "str", ")", ":", "return", "unicode", "(", "s", ",", "er...
Convert an elementary datatype to unicode. Args: s: the datatype to be unicoded. Returns: Unicoded data.
[ "Convert", "an", "elementary", "datatype", "to", "unicode", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L471-L488
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.data_to_unicode
def data_to_unicode(self, data): """Recursively convert a list or dictionary to unicode. Args: data: The data to be unicoded. Returns: Unicoded data. """ if isinstance(data, dict): return {self.to_unicode(k): self.to_unicode(v) for k, v in da...
python
def data_to_unicode(self, data): """Recursively convert a list or dictionary to unicode. Args: data: The data to be unicoded. Returns: Unicoded data. """ if isinstance(data, dict): return {self.to_unicode(k): self.to_unicode(v) for k, v in da...
[ "def", "data_to_unicode", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "{", "self", ".", "to_unicode", "(", "k", ")", ":", "self", ".", "to_unicode", "(", "v", ")", "for", "k", ",", "v", "i...
Recursively convert a list or dictionary to unicode. Args: data: The data to be unicoded. Returns: Unicoded data.
[ "Recursively", "convert", "a", "list", "or", "dictionary", "to", "unicode", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L490-L504
SuperCowPowers/workbench
workbench/workers/timeout_corner/swf_meta.py
SWFMeta.execute
def execute(self, input_data): # Spin up SWF class swf = SWF() # Get the raw_bytes raw_bytes = input_data['sample']['raw_bytes'] # Parse it swf.parse(StringIO(raw_bytes)) # Header info head = swf.header output = {'versio...
python
def execute(self, input_data): # Spin up SWF class swf = SWF() # Get the raw_bytes raw_bytes = input_data['sample']['raw_bytes'] # Parse it swf.parse(StringIO(raw_bytes)) # Header info head = swf.header output = {'versio...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "# Spin up SWF class", "swf", "=", "SWF", "(", ")", "# Get the raw_bytes", "raw_bytes", "=", "input_data", "[", "'sample'", "]", "[", "'raw_bytes'", "]", "# Parse it", "swf", ".", "parse", "(", "Str...
# Map all tag names to indexes tag_map = {tag.name:index for tag,index in enumerate(swf.tags)} # FileAttribute Info file_attr_tag = swf.tags[tag_map]
[ "#", "Map", "all", "tag", "names", "to", "indexes", "tag_map", "=", "{", "tag", ".", "name", ":", "index", "for", "tag", "index", "in", "enumerate", "(", "swf", ".", "tags", ")", "}" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/timeout_corner/swf_meta.py#L14-L52
SuperCowPowers/workbench
workbench/clients/client_helper.py
grab_server_args
def grab_server_args(): """Grab server info from configuration file""" workbench_conf = ConfigParser.ConfigParser() config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.ini') workbench_conf.read(config_path) server = workbench_conf.get('workbench', 'server_uri') p...
python
def grab_server_args(): """Grab server info from configuration file""" workbench_conf = ConfigParser.ConfigParser() config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.ini') workbench_conf.read(config_path) server = workbench_conf.get('workbench', 'server_uri') p...
[ "def", "grab_server_args", "(", ")", ":", "workbench_conf", "=", "ConfigParser", ".", "ConfigParser", "(", ")", "config_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "_...
Grab server info from configuration file
[ "Grab", "server", "info", "from", "configuration", "file" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/client_helper.py#L7-L24
kidig/django-mailjet
django_mailjet/backends.py
MailjetBackend._make_attachment
def _make_attachment(self, attachment, str_encoding=None): """Returns EmailMessage.attachments item formatted for sending with Mailjet Returns mailjet_dict, is_inline_image """ is_inline_image = False if isinstance(attachment, MIMEBase): name = attachment.get_filenam...
python
def _make_attachment(self, attachment, str_encoding=None): """Returns EmailMessage.attachments item formatted for sending with Mailjet Returns mailjet_dict, is_inline_image """ is_inline_image = False if isinstance(attachment, MIMEBase): name = attachment.get_filenam...
[ "def", "_make_attachment", "(", "self", ",", "attachment", ",", "str_encoding", "=", "None", ")", ":", "is_inline_image", "=", "False", "if", "isinstance", "(", "attachment", ",", "MIMEBase", ")", ":", "name", "=", "attachment", ".", "get_filename", "(", ")"...
Returns EmailMessage.attachments item formatted for sending with Mailjet Returns mailjet_dict, is_inline_image
[ "Returns", "EmailMessage", ".", "attachments", "item", "formatted", "for", "sending", "with", "Mailjet" ]
train
https://github.com/kidig/django-mailjet/blob/103dd96383eab6251ae3783d5673050dc90f5a17/django_mailjet/backends.py#L196-L238
SuperCowPowers/workbench
workbench/server/els_indexer.py
ELSIndexer.index_data
def index_data(self, data, index_name, doc_type): """Take an arbitrary dictionary of data and index it with ELS. Args: data: data to be Indexed. Should be a dictionary. index_name: Name of the index. doc_type: The type of the document. Raises: Ru...
python
def index_data(self, data, index_name, doc_type): """Take an arbitrary dictionary of data and index it with ELS. Args: data: data to be Indexed. Should be a dictionary. index_name: Name of the index. doc_type: The type of the document. Raises: Ru...
[ "def", "index_data", "(", "self", ",", "data", ",", "index_name", ",", "doc_type", ")", ":", "# Index the data (which needs to be a dict/object) if it's not", "# we're going to toss an exception", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", ...
Take an arbitrary dictionary of data and index it with ELS. Args: data: data to be Indexed. Should be a dictionary. index_name: Name of the index. doc_type: The type of the document. Raises: RuntimeError: When the Indexing fails.
[ "Take", "an", "arbitrary", "dictionary", "of", "data", "and", "index", "it", "with", "ELS", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/els_indexer.py#L29-L50
SuperCowPowers/workbench
workbench/server/els_indexer.py
ELSIndexer.search
def search(self, index_name, query): """Search the given index_name with the given ELS query. Args: index_name: Name of the Index query: The string to be searched. Returns: List of results. Raises: RuntimeError: When the search query fai...
python
def search(self, index_name, query): """Search the given index_name with the given ELS query. Args: index_name: Name of the Index query: The string to be searched. Returns: List of results. Raises: RuntimeError: When the search query fai...
[ "def", "search", "(", "self", ",", "index_name", ",", "query", ")", ":", "try", ":", "results", "=", "self", ".", "els_search", ".", "search", "(", "index", "=", "index_name", ",", "body", "=", "query", ")", "return", "results", "except", "Exception", ...
Search the given index_name with the given ELS query. Args: index_name: Name of the Index query: The string to be searched. Returns: List of results. Raises: RuntimeError: When the search query fails.
[ "Search", "the", "given", "index_name", "with", "the", "given", "ELS", "query", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/els_indexer.py#L52-L73
SuperCowPowers/workbench
workbench/server/els_indexer.py
ELSStubIndexer.index_data
def index_data(self, data, index_name, doc_type): """Index data in Stub Indexer.""" print 'ELS Stub Indexer getting called...' print '%s %s %s %s' % (self, data, index_name, doc_type)
python
def index_data(self, data, index_name, doc_type): """Index data in Stub Indexer.""" print 'ELS Stub Indexer getting called...' print '%s %s %s %s' % (self, data, index_name, doc_type)
[ "def", "index_data", "(", "self", ",", "data", ",", "index_name", ",", "doc_type", ")", ":", "print", "'ELS Stub Indexer getting called...'", "print", "'%s %s %s %s'", "%", "(", "self", ",", "data", ",", "index_name", ",", "doc_type", ")" ]
Index data in Stub Indexer.
[ "Index", "data", "in", "Stub", "Indexer", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/els_indexer.py#L86-L90
SuperCowPowers/workbench
workbench/workers/pe_deep_sim.py
PEDeepSim.execute
def execute(self, input_data): ''' Execute method ''' my_ssdeep = input_data['meta_deep']['ssdeep'] my_md5 = input_data['meta_deep']['md5'] # For every PE sample in the database compute my ssdeep fuzzy match sample_set = self.workbench.generate_sample_set('exe') results ...
python
def execute(self, input_data): ''' Execute method ''' my_ssdeep = input_data['meta_deep']['ssdeep'] my_md5 = input_data['meta_deep']['md5'] # For every PE sample in the database compute my ssdeep fuzzy match sample_set = self.workbench.generate_sample_set('exe') results ...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "my_ssdeep", "=", "input_data", "[", "'meta_deep'", "]", "[", "'ssdeep'", "]", "my_md5", "=", "input_data", "[", "'meta_deep'", "]", "[", "'md5'", "]", "# For every PE sample in the database compute my ss...
Execute method
[ "Execute", "method" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pe_deep_sim.py#L18-L34
SuperCowPowers/workbench
workbench/workers/help_formatter.py
HelpFormatter.execute
def execute(self, input_data): ''' Do CLI formatting and coloring based on the type_tag ''' input_data = input_data['help_base'] type_tag = input_data['type_tag'] # Standard help text if type_tag == 'help': output = '%s%s%s' % (color.LightBlue, input_data['help'], co...
python
def execute(self, input_data): ''' Do CLI formatting and coloring based on the type_tag ''' input_data = input_data['help_base'] type_tag = input_data['type_tag'] # Standard help text if type_tag == 'help': output = '%s%s%s' % (color.LightBlue, input_data['help'], co...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "input_data", "=", "input_data", "[", "'help_base'", "]", "type_tag", "=", "input_data", "[", "'type_tag'", "]", "# Standard help text", "if", "type_tag", "==", "'help'", ":", "output", "=", "'%s%s%s'...
Do CLI formatting and coloring based on the type_tag
[ "Do", "CLI", "formatting", "and", "coloring", "based", "on", "the", "type_tag" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/help_formatter.py#L11-L37
SuperCowPowers/workbench
workbench/server/workbench_server.py
run
def run(): """ Run the workbench server """ # Load the configuration file relative to this script location config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.ini') workbench_conf = ConfigParser.ConfigParser() config_ini = workbench_conf.read(config_path) if not conf...
python
def run(): """ Run the workbench server """ # Load the configuration file relative to this script location config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config.ini') workbench_conf = ConfigParser.ConfigParser() config_ini = workbench_conf.read(config_path) if not conf...
[ "def", "run", "(", ")", ":", "# Load the configuration file relative to this script location", "config_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", ","...
Run the workbench server
[ "Run", "the", "workbench", "server" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L844-L874
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.store_sample
def store_sample(self, input_bytes, filename, type_tag): """ Store a sample into the DataStore. Args: input_bytes: the actual bytes of the sample e.g. f.read() filename: name of the file (used purely as meta data not for lookup) type_tag: ('exe','pcap'...
python
def store_sample(self, input_bytes, filename, type_tag): """ Store a sample into the DataStore. Args: input_bytes: the actual bytes of the sample e.g. f.read() filename: name of the file (used purely as meta data not for lookup) type_tag: ('exe','pcap'...
[ "def", "store_sample", "(", "self", ",", "input_bytes", ",", "filename", ",", "type_tag", ")", ":", "# If the sample comes in with an unknown type_tag try to determine it", "if", "type_tag", "==", "'unknown'", ":", "print", "'Info: Unknown File -- Trying to Determine Type...'",...
Store a sample into the DataStore. Args: input_bytes: the actual bytes of the sample e.g. f.read() filename: name of the file (used purely as meta data not for lookup) type_tag: ('exe','pcap','pdf','json','swf', or ...) Returns: the...
[ "Store", "a", "sample", "into", "the", "DataStore", ".", "Args", ":", "input_bytes", ":", "the", "actual", "bytes", "of", "the", "sample", "e", ".", "g", ".", "f", ".", "read", "()", "filename", ":", "name", "of", "the", "file", "(", "used", "purely"...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L107-L133
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.get_sample
def get_sample(self, md5): """ Get a sample from the DataStore. Args: md5: the md5 of the sample Returns: A dictionary of meta data about the sample which includes a ['raw_bytes'] key that contains the raw bytes. Raises: ...
python
def get_sample(self, md5): """ Get a sample from the DataStore. Args: md5: the md5 of the sample Returns: A dictionary of meta data about the sample which includes a ['raw_bytes'] key that contains the raw bytes. Raises: ...
[ "def", "get_sample", "(", "self", ",", "md5", ")", ":", "# First we try a sample, if we can't find one we try getting a sample_set.", "sample", "=", "self", ".", "data_store", ".", "get_sample", "(", "md5", ")", "if", "not", "sample", ":", "return", "{", "'sample_se...
Get a sample from the DataStore. Args: md5: the md5 of the sample Returns: A dictionary of meta data about the sample which includes a ['raw_bytes'] key that contains the raw bytes. Raises: Workbench.DataNotFound if the ...
[ "Get", "a", "sample", "from", "the", "DataStore", ".", "Args", ":", "md5", ":", "the", "md5", "of", "the", "sample", "Returns", ":", "A", "dictionary", "of", "meta", "data", "about", "the", "sample", "which", "includes", "a", "[", "raw_bytes", "]", "ke...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L135-L149
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.is_sample_set
def is_sample_set(self, md5): """ Does the md5 represent a sample_set? Args: md5: the md5 of the sample_set Returns: True/False """ try: self.get_sample_set(md5) return True except WorkBench.DataNotFound: ...
python
def is_sample_set(self, md5): """ Does the md5 represent a sample_set? Args: md5: the md5 of the sample_set Returns: True/False """ try: self.get_sample_set(md5) return True except WorkBench.DataNotFound: ...
[ "def", "is_sample_set", "(", "self", ",", "md5", ")", ":", "try", ":", "self", ".", "get_sample_set", "(", "md5", ")", "return", "True", "except", "WorkBench", ".", "DataNotFound", ":", "return", "False" ]
Does the md5 represent a sample_set? Args: md5: the md5 of the sample_set Returns: True/False
[ "Does", "the", "md5", "represent", "a", "sample_set?", "Args", ":", "md5", ":", "the", "md5", "of", "the", "sample_set", "Returns", ":", "True", "/", "False" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L151-L162
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.get_sample_window
def get_sample_window(self, type_tag, size): """ Get a sample from the DataStore. Args: type_tag: the type of samples ('pcap','exe','pdf') size: the size of the window in MegaBytes (10 = 10MB) Returns: A sample_set handle which represents t...
python
def get_sample_window(self, type_tag, size): """ Get a sample from the DataStore. Args: type_tag: the type of samples ('pcap','exe','pdf') size: the size of the window in MegaBytes (10 = 10MB) Returns: A sample_set handle which represents t...
[ "def", "get_sample_window", "(", "self", ",", "type_tag", ",", "size", ")", ":", "md5_list", "=", "self", ".", "data_store", ".", "get_sample_window", "(", "type_tag", ",", "size", ")", "return", "self", ".", "store_sample_set", "(", "md5_list", ")" ]
Get a sample from the DataStore. Args: type_tag: the type of samples ('pcap','exe','pdf') size: the size of the window in MegaBytes (10 = 10MB) Returns: A sample_set handle which represents the newest samples within the size window
[ "Get", "a", "sample", "from", "the", "DataStore", ".", "Args", ":", "type_tag", ":", "the", "type", "of", "samples", "(", "pcap", "exe", "pdf", ")", "size", ":", "the", "size", "of", "the", "window", "in", "MegaBytes", "(", "10", "=", "10MB", ")", ...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L164-L173
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.combine_samples
def combine_samples(self, md5_list, filename, type_tag): """Combine samples together. This may have various use cases the most significant involving a bunch of sample 'chunks' got uploaded and now we combine them together Args: md5_list: The list of md5s to combine, orde...
python
def combine_samples(self, md5_list, filename, type_tag): """Combine samples together. This may have various use cases the most significant involving a bunch of sample 'chunks' got uploaded and now we combine them together Args: md5_list: The list of md5s to combine, orde...
[ "def", "combine_samples", "(", "self", ",", "md5_list", ",", "filename", ",", "type_tag", ")", ":", "total_bytes", "=", "\"\"", "for", "md5", "in", "md5_list", ":", "total_bytes", "+=", "self", ".", "get_sample", "(", "md5", ")", "[", "'sample'", "]", "[...
Combine samples together. This may have various use cases the most significant involving a bunch of sample 'chunks' got uploaded and now we combine them together Args: md5_list: The list of md5s to combine, order matters! filename: name of the file (used purely a...
[ "Combine", "samples", "together", ".", "This", "may", "have", "various", "use", "cases", "the", "most", "significant", "involving", "a", "bunch", "of", "sample", "chunks", "got", "uploaded", "and", "now", "we", "combine", "them", "together" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L184-L201
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.stream_sample
def stream_sample(self, md5, kwargs=None): """ Stream the sample by giving back a generator, typically used on 'logs'. Args: md5: the md5 of the sample kwargs: a way of specifying subsets of samples (None for all) max_rows: the maximum number of ro...
python
def stream_sample(self, md5, kwargs=None): """ Stream the sample by giving back a generator, typically used on 'logs'. Args: md5: the md5 of the sample kwargs: a way of specifying subsets of samples (None for all) max_rows: the maximum number of ro...
[ "def", "stream_sample", "(", "self", ",", "md5", ",", "kwargs", "=", "None", ")", ":", "# Get the max_rows if specified", "max_rows", "=", "kwargs", ".", "get", "(", "'max_rows'", ",", "None", ")", "if", "kwargs", "else", "None", "# Grab the sample and it's raw ...
Stream the sample by giving back a generator, typically used on 'logs'. Args: md5: the md5 of the sample kwargs: a way of specifying subsets of samples (None for all) max_rows: the maximum number of rows to return Returns: A gen...
[ "Stream", "the", "sample", "by", "giving", "back", "a", "generator", "typically", "used", "on", "logs", ".", "Args", ":", "md5", ":", "the", "md5", "of", "the", "sample", "kwargs", ":", "a", "way", "of", "specifying", "subsets", "of", "samples", "(", "...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L208-L247
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.get_dataframe
def get_dataframe(self, md5, compress='lz4'): """Return a dataframe from the DataStore. This is just a convenience method that uses get_sample internally. Args: md5: the md5 of the dataframe compress: compression to use: (defaults to 'lz4' but can be set t...
python
def get_dataframe(self, md5, compress='lz4'): """Return a dataframe from the DataStore. This is just a convenience method that uses get_sample internally. Args: md5: the md5 of the dataframe compress: compression to use: (defaults to 'lz4' but can be set t...
[ "def", "get_dataframe", "(", "self", ",", "md5", ",", "compress", "=", "'lz4'", ")", ":", "# First we try a sample, if we can't find one we try getting a sample_set.", "sample", "=", "self", ".", "data_store", ".", "get_sample", "(", "md5", ")", "if", "not", "sample...
Return a dataframe from the DataStore. This is just a convenience method that uses get_sample internally. Args: md5: the md5 of the dataframe compress: compression to use: (defaults to 'lz4' but can be set to None) Returns: A msgpack'd ...
[ "Return", "a", "dataframe", "from", "the", "DataStore", ".", "This", "is", "just", "a", "convenience", "method", "that", "uses", "get_sample", "internally", ".", "Args", ":", "md5", ":", "the", "md5", "of", "the", "dataframe", "compress", ":", "compression",...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L249-L269
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.guess_type_tag
def guess_type_tag(self, input_bytes, filename): """ Try to guess the type_tag for this sample """ mime_to_type = {'application/jar': 'jar', 'application/java-archive': 'jar', 'application/octet-stream': 'data', 'application/pdf': '...
python
def guess_type_tag(self, input_bytes, filename): """ Try to guess the type_tag for this sample """ mime_to_type = {'application/jar': 'jar', 'application/java-archive': 'jar', 'application/octet-stream': 'data', 'application/pdf': '...
[ "def", "guess_type_tag", "(", "self", ",", "input_bytes", ",", "filename", ")", ":", "mime_to_type", "=", "{", "'application/jar'", ":", "'jar'", ",", "'application/java-archive'", ":", "'jar'", ",", "'application/octet-stream'", ":", "'data'", ",", "'application/pd...
Try to guess the type_tag for this sample
[ "Try", "to", "guess", "the", "type_tag", "for", "this", "sample" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L271-L311
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.add_tags
def add_tags(self, md5, tags): """Add tags to this sample""" if not tags: return tag_set = set(self.get_tags(md5)) if self.get_tags(md5) else set() if isinstance(tags, str): tags = [tags] for tag in tags: tag_set.add(tag) self.data_store.store_work...
python
def add_tags(self, md5, tags): """Add tags to this sample""" if not tags: return tag_set = set(self.get_tags(md5)) if self.get_tags(md5) else set() if isinstance(tags, str): tags = [tags] for tag in tags: tag_set.add(tag) self.data_store.store_work...
[ "def", "add_tags", "(", "self", ",", "md5", ",", "tags", ")", ":", "if", "not", "tags", ":", "return", "tag_set", "=", "set", "(", "self", ".", "get_tags", "(", "md5", ")", ")", "if", "self", ".", "get_tags", "(", "md5", ")", "else", "set", "(", ...
Add tags to this sample
[ "Add", "tags", "to", "this", "sample" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L313-L321
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.set_tags
def set_tags(self, md5, tags): """Set the tags for this sample""" if isinstance(tags, str): tags = [tags] tag_set = set(tags) self.data_store.store_work_results({'tags': list(tag_set)}, 'tags', md5)
python
def set_tags(self, md5, tags): """Set the tags for this sample""" if isinstance(tags, str): tags = [tags] tag_set = set(tags) self.data_store.store_work_results({'tags': list(tag_set)}, 'tags', md5)
[ "def", "set_tags", "(", "self", ",", "md5", ",", "tags", ")", ":", "if", "isinstance", "(", "tags", ",", "str", ")", ":", "tags", "=", "[", "tags", "]", "tag_set", "=", "set", "(", "tags", ")", "self", ".", "data_store", ".", "store_work_results", ...
Set the tags for this sample
[ "Set", "the", "tags", "for", "this", "sample" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L323-L328
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.get_tags
def get_tags(self, md5): """Get tags for this sample""" tag_data = self.data_store.get_work_results('tags', md5) return tag_data['tags'] if tag_data else None
python
def get_tags(self, md5): """Get tags for this sample""" tag_data = self.data_store.get_work_results('tags', md5) return tag_data['tags'] if tag_data else None
[ "def", "get_tags", "(", "self", ",", "md5", ")", ":", "tag_data", "=", "self", ".", "data_store", ".", "get_work_results", "(", "'tags'", ",", "md5", ")", "return", "tag_data", "[", "'tags'", "]", "if", "tag_data", "else", "None" ]
Get tags for this sample
[ "Get", "tags", "for", "this", "sample" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L330-L333
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.index_sample
def index_sample(self, md5, index_name): """ Index a stored sample with the Indexer. Args: md5: the md5 of the sample index_name: the name of the index Returns: Nothing """ generator = self.stream_sample(md5) for row...
python
def index_sample(self, md5, index_name): """ Index a stored sample with the Indexer. Args: md5: the md5 of the sample index_name: the name of the index Returns: Nothing """ generator = self.stream_sample(md5) for row...
[ "def", "index_sample", "(", "self", ",", "md5", ",", "index_name", ")", ":", "generator", "=", "self", ".", "stream_sample", "(", "md5", ")", "for", "row", "in", "generator", ":", "self", ".", "indexer", ".", "index_data", "(", "row", ",", "index_name", ...
Index a stored sample with the Indexer. Args: md5: the md5 of the sample index_name: the name of the index Returns: Nothing
[ "Index", "a", "stored", "sample", "with", "the", "Indexer", ".", "Args", ":", "md5", ":", "the", "md5", "of", "the", "sample", "index_name", ":", "the", "name", "of", "the", "index", "Returns", ":", "Nothing" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L343-L353
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.index_worker_output
def index_worker_output(self, worker_name, md5, index_name, subfield): """ Index worker output with the Indexer. Args: worker_name: 'strings', 'pe_features', whatever md5: the md5 of the sample index_name: the name of the index subfield...
python
def index_worker_output(self, worker_name, md5, index_name, subfield): """ Index worker output with the Indexer. Args: worker_name: 'strings', 'pe_features', whatever md5: the md5 of the sample index_name: the name of the index subfield...
[ "def", "index_worker_output", "(", "self", ",", "worker_name", ",", "md5", ",", "index_name", ",", "subfield", ")", ":", "# Grab the data", "if", "subfield", ":", "data", "=", "self", ".", "work_request", "(", "worker_name", ",", "md5", ")", "[", "worker_nam...
Index worker output with the Indexer. Args: worker_name: 'strings', 'pe_features', whatever md5: the md5 of the sample index_name: the name of the index subfield: index just this subfield (None for all) Returns: Noth...
[ "Index", "worker", "output", "with", "the", "Indexer", ".", "Args", ":", "worker_name", ":", "strings", "pe_features", "whatever", "md5", ":", "the", "md5", "of", "the", "sample", "index_name", ":", "the", "name", "of", "the", "index", "subfield", ":", "in...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L355-L373
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.add_node
def add_node(self, node_id, name, labels): """ Add a node to the graph with name and labels. Args: node_id: the unique node_id e.g. 'www.evil4u.com' name: the display name of the node e.g. 'evil4u' labels: a list of labels e.g. ['domain','evil'] ...
python
def add_node(self, node_id, name, labels): """ Add a node to the graph with name and labels. Args: node_id: the unique node_id e.g. 'www.evil4u.com' name: the display name of the node e.g. 'evil4u' labels: a list of labels e.g. ['domain','evil'] ...
[ "def", "add_node", "(", "self", ",", "node_id", ",", "name", ",", "labels", ")", ":", "self", ".", "neo_db", ".", "add_node", "(", "node_id", ",", "name", ",", "labels", ")" ]
Add a node to the graph with name and labels. Args: node_id: the unique node_id e.g. 'www.evil4u.com' name: the display name of the node e.g. 'evil4u' labels: a list of labels e.g. ['domain','evil'] Returns: Nothing
[ "Add", "a", "node", "to", "the", "graph", "with", "name", "and", "labels", ".", "Args", ":", "node_id", ":", "the", "unique", "node_id", "e", ".", "g", ".", "www", ".", "evil4u", ".", "com", "name", ":", "the", "display", "name", "of", "the", "node...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L389-L398
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.add_rel
def add_rel(self, source_id, target_id, rel): """ Add a relationship: source, target must already exist (see add_node) 'rel' is the name of the relationship 'contains' or whatever. Args: source_id: the unique node_id of the source target_id: the unique nod...
python
def add_rel(self, source_id, target_id, rel): """ Add a relationship: source, target must already exist (see add_node) 'rel' is the name of the relationship 'contains' or whatever. Args: source_id: the unique node_id of the source target_id: the unique nod...
[ "def", "add_rel", "(", "self", ",", "source_id", ",", "target_id", ",", "rel", ")", ":", "self", ".", "neo_db", ".", "add_rel", "(", "source_id", ",", "target_id", ",", "rel", ")" ]
Add a relationship: source, target must already exist (see add_node) 'rel' is the name of the relationship 'contains' or whatever. Args: source_id: the unique node_id of the source target_id: the unique node_id of the target rel: name of the relati...
[ "Add", "a", "relationship", ":", "source", "target", "must", "already", "exist", "(", "see", "add_node", ")", "rel", "is", "the", "name", "of", "the", "relationship", "contains", "or", "whatever", ".", "Args", ":", "source_id", ":", "the", "unique", "node_...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L409-L419
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.clear_db
def clear_db(self): """ Clear the Main Database of all samples and worker output. Args: None Returns: Nothing """ self.data_store.clear_db() # Have the plugin manager reload all the plugins self.plugin_manager.load_all_plug...
python
def clear_db(self): """ Clear the Main Database of all samples and worker output. Args: None Returns: Nothing """ self.data_store.clear_db() # Have the plugin manager reload all the plugins self.plugin_manager.load_all_plug...
[ "def", "clear_db", "(", "self", ")", ":", "self", ".", "data_store", ".", "clear_db", "(", ")", "# Have the plugin manager reload all the plugins", "self", ".", "plugin_manager", ".", "load_all_plugins", "(", ")", "# Store information about commands and workbench", "self"...
Clear the Main Database of all samples and worker output. Args: None Returns: Nothing
[ "Clear", "the", "Main", "Database", "of", "all", "samples", "and", "worker", "output", ".", "Args", ":", "None", "Returns", ":", "Nothing" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L430-L443
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.clear_worker_output
def clear_worker_output(self): """Drops all of the worker output collections Args: None Returns: Nothing """ self.data_store.clear_worker_output() # Have the plugin manager reload all the plugins self.plugin_manager.load_al...
python
def clear_worker_output(self): """Drops all of the worker output collections Args: None Returns: Nothing """ self.data_store.clear_worker_output() # Have the plugin manager reload all the plugins self.plugin_manager.load_al...
[ "def", "clear_worker_output", "(", "self", ")", ":", "self", ".", "data_store", ".", "clear_worker_output", "(", ")", "# Have the plugin manager reload all the plugins", "self", ".", "plugin_manager", ".", "load_all_plugins", "(", ")", "# Store information about commands an...
Drops all of the worker output collections Args: None Returns: Nothing
[ "Drops", "all", "of", "the", "worker", "output", "collections", "Args", ":", "None", "Returns", ":", "Nothing" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L445-L458
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.work_request
def work_request(self, worker_name, md5, subkeys=None): """ Make a work request for an existing stored sample. Args: worker_name: 'strings', 'pe_features', whatever md5: the md5 of the sample (or sample_set!) subkeys: just get a subkey of the output: '...
python
def work_request(self, worker_name, md5, subkeys=None): """ Make a work request for an existing stored sample. Args: worker_name: 'strings', 'pe_features', whatever md5: the md5 of the sample (or sample_set!) subkeys: just get a subkey of the output: '...
[ "def", "work_request", "(", "self", ",", "worker_name", ",", "md5", ",", "subkeys", "=", "None", ")", ":", "# Pull the worker output", "work_results", "=", "self", ".", "_recursive_work_resolver", "(", "worker_name", ",", "md5", ")", "# Subkeys (Fixme this is super ...
Make a work request for an existing stored sample. Args: worker_name: 'strings', 'pe_features', whatever md5: the md5 of the sample (or sample_set!) subkeys: just get a subkey of the output: 'foo' or 'foo.bar' (None for all) Returns: ...
[ "Make", "a", "work", "request", "for", "an", "existing", "stored", "sample", ".", "Args", ":", "worker_name", ":", "strings", "pe_features", "whatever", "md5", ":", "the", "md5", "of", "the", "sample", "(", "or", "sample_set!", ")", "subkeys", ":", "just",...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L464-L505
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.set_work_request
def set_work_request(self, worker_name, sample_set, subkeys=None): """ Make a work request for an existing stored sample (or sample_set). Args: worker_name: 'strings', 'pe_features', whatever sample_set: the md5 of a sample_set in the Workbench data store ...
python
def set_work_request(self, worker_name, sample_set, subkeys=None): """ Make a work request for an existing stored sample (or sample_set). Args: worker_name: 'strings', 'pe_features', whatever sample_set: the md5 of a sample_set in the Workbench data store ...
[ "def", "set_work_request", "(", "self", ",", "worker_name", ",", "sample_set", ",", "subkeys", "=", "None", ")", ":", "# Does worker support sample_set_input?", "if", "self", ".", "plugin_meta", "[", "worker_name", "]", "[", "'sample_set_input'", "]", ":", "yield"...
Make a work request for an existing stored sample (or sample_set). Args: worker_name: 'strings', 'pe_features', whatever sample_set: the md5 of a sample_set in the Workbench data store subkeys: just get a subkey of the output: 'foo' or 'foo.bar' (None for all)...
[ "Make", "a", "work", "request", "for", "an", "existing", "stored", "sample", "(", "or", "sample_set", ")", ".", "Args", ":", "worker_name", ":", "strings", "pe_features", "whatever", "sample_set", ":", "the", "md5", "of", "a", "sample_set", "in", "the", "W...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L508-L529
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.store_sample_set
def store_sample_set(self, md5_list): """ Store a sample set (which is just a list of md5s). Note: All md5s must already be in the data store. Args: md5_list: a list of the md5s in this set (all must exist in data store) Returns: The md5 of ...
python
def store_sample_set(self, md5_list): """ Store a sample set (which is just a list of md5s). Note: All md5s must already be in the data store. Args: md5_list: a list of the md5s in this set (all must exist in data store) Returns: The md5 of ...
[ "def", "store_sample_set", "(", "self", ",", "md5_list", ")", ":", "# Sanity check", "if", "not", "md5_list", ":", "print", "'Warning: Trying to store an empty sample_set'", "return", "None", "# Remove any duplicates", "md5_list", "=", "list", "(", "set", "(", "md5_li...
Store a sample set (which is just a list of md5s). Note: All md5s must already be in the data store. Args: md5_list: a list of the md5s in this set (all must exist in data store) Returns: The md5 of the set (the actual md5 of the set)
[ "Store", "a", "sample", "set", "(", "which", "is", "just", "a", "list", "of", "md5s", ")", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L531-L556
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.generate_sample_set
def generate_sample_set(self, tags=None): """Generate a sample_set that maches the tags or all if tags are not specified. Args: tags: Match samples against this tag list (or all if not specified) Returns: The sample_set of those samples matching the tags...
python
def generate_sample_set(self, tags=None): """Generate a sample_set that maches the tags or all if tags are not specified. Args: tags: Match samples against this tag list (or all if not specified) Returns: The sample_set of those samples matching the tags...
[ "def", "generate_sample_set", "(", "self", ",", "tags", "=", "None", ")", ":", "if", "isinstance", "(", "tags", ",", "str", ")", ":", "tags", "=", "[", "tags", "]", "md5_list", "=", "self", ".", "data_store", ".", "tag_match", "(", "tags", ")", "retu...
Generate a sample_set that maches the tags or all if tags are not specified. Args: tags: Match samples against this tag list (or all if not specified) Returns: The sample_set of those samples matching the tags
[ "Generate", "a", "sample_set", "that", "maches", "the", "tags", "or", "all", "if", "tags", "are", "not", "specified", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L558-L570
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.help
def help(self, topic=None): """ Returns the formatted, colored help """ if not topic: topic = 'workbench' # It's possible to ask for help on something that doesn't exist # so we'll catch the exception and push back an object that # indicates we didn't find what they ...
python
def help(self, topic=None): """ Returns the formatted, colored help """ if not topic: topic = 'workbench' # It's possible to ask for help on something that doesn't exist # so we'll catch the exception and push back an object that # indicates we didn't find what they ...
[ "def", "help", "(", "self", ",", "topic", "=", "None", ")", ":", "if", "not", "topic", ":", "topic", "=", "'workbench'", "# It's possible to ask for help on something that doesn't exist", "# so we'll catch the exception and push back an object that", "# indicates we didn't find...
Returns the formatted, colored help
[ "Returns", "the", "formatted", "colored", "help" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L611-L627
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._help_workbench
def _help_workbench(self): """ Help on Workbench """ help = '%sWelcome to Workbench Help:%s' % (color.Yellow, color.Normal) help += '\n\t%s- workbench.help(\'basic\') %s for getting started help' % (color.Green, color.LightBlue) help += '\n\t%s- workbench.help(\'workers\') %s for help on...
python
def _help_workbench(self): """ Help on Workbench """ help = '%sWelcome to Workbench Help:%s' % (color.Yellow, color.Normal) help += '\n\t%s- workbench.help(\'basic\') %s for getting started help' % (color.Green, color.LightBlue) help += '\n\t%s- workbench.help(\'workers\') %s for help on...
[ "def", "_help_workbench", "(", "self", ")", ":", "help", "=", "'%sWelcome to Workbench Help:%s'", "%", "(", "color", ".", "Yellow", ",", "color", ".", "Normal", ")", "help", "+=", "'\\n\\t%s- workbench.help(\\'basic\\') %s for getting started help'", "%", "(", "color"...
Help on Workbench
[ "Help", "on", "Workbench" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L630-L638
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._help_basic
def _help_basic(self): """ Help for Workbench Basics """ help = '%sWorkbench: Getting started...' % (color.Yellow) help += '\n%sStore a sample into Workbench:' % (color.Green) help += '\n\t%s$ workbench.store_sample(raw_bytes, filename, type_tag)' % (color.LightBlue) help += '\...
python
def _help_basic(self): """ Help for Workbench Basics """ help = '%sWorkbench: Getting started...' % (color.Yellow) help += '\n%sStore a sample into Workbench:' % (color.Green) help += '\n\t%s$ workbench.store_sample(raw_bytes, filename, type_tag)' % (color.LightBlue) help += '\...
[ "def", "_help_basic", "(", "self", ")", ":", "help", "=", "'%sWorkbench: Getting started...'", "%", "(", "color", ".", "Yellow", ")", "help", "+=", "'\\n%sStore a sample into Workbench:'", "%", "(", "color", ".", "Green", ")", "help", "+=", "'\\n\\t%s$ workbench.s...
Help for Workbench Basics
[ "Help", "for", "Workbench", "Basics" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L640-L648
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._help_commands
def _help_commands(self): """ Help on all the available commands """ help = 'Workbench Commands:' for command in self.list_all_commands(): full_help = self.work_request('help_formatter', command)['help_formatter']['help'] compact_help = full_help.split('\n')[:2] ...
python
def _help_commands(self): """ Help on all the available commands """ help = 'Workbench Commands:' for command in self.list_all_commands(): full_help = self.work_request('help_formatter', command)['help_formatter']['help'] compact_help = full_help.split('\n')[:2] ...
[ "def", "_help_commands", "(", "self", ")", ":", "help", "=", "'Workbench Commands:'", "for", "command", "in", "self", ".", "list_all_commands", "(", ")", ":", "full_help", "=", "self", ".", "work_request", "(", "'help_formatter'", ",", "command", ")", "[", "...
Help on all the available commands
[ "Help", "on", "all", "the", "available", "commands" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L650-L657
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._help_workers
def _help_workers(self): """ Help on all the available workers """ help = 'Workbench Workers:' for worker in self.list_all_workers(): full_help = self.work_request('help_formatter', worker)['help_formatter']['help'] compact_help = full_help.split('\n')[:4] he...
python
def _help_workers(self): """ Help on all the available workers """ help = 'Workbench Workers:' for worker in self.list_all_workers(): full_help = self.work_request('help_formatter', worker)['help_formatter']['help'] compact_help = full_help.split('\n')[:4] he...
[ "def", "_help_workers", "(", "self", ")", ":", "help", "=", "'Workbench Workers:'", "for", "worker", "in", "self", ".", "list_all_workers", "(", ")", ":", "full_help", "=", "self", ".", "work_request", "(", "'help_formatter'", ",", "worker", ")", "[", "'help...
Help on all the available workers
[ "Help", "on", "all", "the", "available", "workers" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L659-L666
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.list_all_commands
def list_all_commands(self): """ Returns a list of all the Workbench commands""" commands = [name for name, _ in inspect.getmembers(self, predicate=inspect.isroutine) if not name.startswith('_')] return commands
python
def list_all_commands(self): """ Returns a list of all the Workbench commands""" commands = [name for name, _ in inspect.getmembers(self, predicate=inspect.isroutine) if not name.startswith('_')] return commands
[ "def", "list_all_commands", "(", "self", ")", ":", "commands", "=", "[", "name", "for", "name", ",", "_", "in", "inspect", ".", "getmembers", "(", "self", ",", "predicate", "=", "inspect", ".", "isroutine", ")", "if", "not", "name", ".", "startswith", ...
Returns a list of all the Workbench commands
[ "Returns", "a", "list", "of", "all", "the", "Workbench", "commands" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L672-L675
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.get_info
def get_info(self, component): """ Get the information about this component """ # Grab it, clean it and ship it work_results = self._get_work_results('info', component) return self.data_store.clean_for_serialization(work_results)
python
def get_info(self, component): """ Get the information about this component """ # Grab it, clean it and ship it work_results = self._get_work_results('info', component) return self.data_store.clean_for_serialization(work_results)
[ "def", "get_info", "(", "self", ",", "component", ")", ":", "# Grab it, clean it and ship it", "work_results", "=", "self", ".", "_get_work_results", "(", "'info'", ",", "component", ")", "return", "self", ".", "data_store", ".", "clean_for_serialization", "(", "w...
Get the information about this component
[ "Get", "the", "information", "about", "this", "component" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L681-L686
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench.store_info
def store_info(self, info_dict, component, type_tag): """ Store information about a component. The component could be a worker or a commands or a class, or whatever you want, the only thing to be aware of is name collisions. """ # Enforce dictionary input if not isinstan...
python
def store_info(self, info_dict, component, type_tag): """ Store information about a component. The component could be a worker or a commands or a class, or whatever you want, the only thing to be aware of is name collisions. """ # Enforce dictionary input if not isinstan...
[ "def", "store_info", "(", "self", ",", "info_dict", ",", "component", ",", "type_tag", ")", ":", "# Enforce dictionary input", "if", "not", "isinstance", "(", "info_dict", ",", "dict", ")", ":", "print", "'Critical: info_dict must be a python dictionary, got %s'", "%"...
Store information about a component. The component could be a worker or a commands or a class, or whatever you want, the only thing to be aware of is name collisions.
[ "Store", "information", "about", "a", "component", ".", "The", "component", "could", "be", "a", "worker", "or", "a", "commands", "or", "a", "class", "or", "whatever", "you", "want", "the", "only", "thing", "to", "be", "aware", "of", "is", "name", "collis...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L688-L703
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._store_information
def _store_information(self): """ Store infomation about Workbench and its commands """ print '<<< Generating Information Storage >>>' # Stores information on Workbench commands and signatures for name, meth in inspect.getmembers(self, predicate=inspect.isroutine): ...
python
def _store_information(self): """ Store infomation about Workbench and its commands """ print '<<< Generating Information Storage >>>' # Stores information on Workbench commands and signatures for name, meth in inspect.getmembers(self, predicate=inspect.isroutine): ...
[ "def", "_store_information", "(", "self", ")", ":", "print", "'<<< Generating Information Storage >>>'", "# Stores information on Workbench commands and signatures", "for", "name", ",", "meth", "in", "inspect", ".", "getmembers", "(", "self", ",", "predicate", "=", "inspe...
Store infomation about Workbench and its commands
[ "Store", "infomation", "about", "Workbench", "and", "its", "commands" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L729-L745
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._new_plugin
def _new_plugin(self, plugin): """ Internal: This method handles the mechanics around new plugins. """ # First store the plugin info into our data store self.store_info(plugin, plugin['name'], type_tag='worker') # Place it into our active plugin list self.plugin_meta[plugin['na...
python
def _new_plugin(self, plugin): """ Internal: This method handles the mechanics around new plugins. """ # First store the plugin info into our data store self.store_info(plugin, plugin['name'], type_tag='worker') # Place it into our active plugin list self.plugin_meta[plugin['na...
[ "def", "_new_plugin", "(", "self", ",", "plugin", ")", ":", "# First store the plugin info into our data store", "self", ".", "store_info", "(", "plugin", ",", "plugin", "[", "'name'", "]", ",", "type_tag", "=", "'worker'", ")", "# Place it into our active plugin list...
Internal: This method handles the mechanics around new plugins.
[ "Internal", ":", "This", "method", "handles", "the", "mechanics", "around", "new", "plugins", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L747-L754
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._store_work_results
def _store_work_results(self, results, collection, md5): """ Internal: Stores the work results of a worker.""" self.data_store.store_work_results(results, collection, md5)
python
def _store_work_results(self, results, collection, md5): """ Internal: Stores the work results of a worker.""" self.data_store.store_work_results(results, collection, md5)
[ "def", "_store_work_results", "(", "self", ",", "results", ",", "collection", ",", "md5", ")", ":", "self", ".", "data_store", ".", "store_work_results", "(", "results", ",", "collection", ",", "md5", ")" ]
Internal: Stores the work results of a worker.
[ "Internal", ":", "Stores", "the", "work", "results", "of", "a", "worker", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L756-L758
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._get_work_results
def _get_work_results(self, collection, md5): """ Internal: Method for fetching work results.""" results = self.data_store.get_work_results(collection, md5) if not results: raise WorkBench.DataNotFound(md5 + ': Data/Sample not found...') return {collection: results}
python
def _get_work_results(self, collection, md5): """ Internal: Method for fetching work results.""" results = self.data_store.get_work_results(collection, md5) if not results: raise WorkBench.DataNotFound(md5 + ': Data/Sample not found...') return {collection: results}
[ "def", "_get_work_results", "(", "self", ",", "collection", ",", "md5", ")", ":", "results", "=", "self", ".", "data_store", ".", "get_work_results", "(", "collection", ",", "md5", ")", "if", "not", "results", ":", "raise", "WorkBench", ".", "DataNotFound", ...
Internal: Method for fetching work results.
[ "Internal", ":", "Method", "for", "fetching", "work", "results", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L759-L764
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._work_chain_mod_time
def _work_chain_mod_time(self, worker_name): """ Internal: We compute a modification time of a work chain. Returns: The newest modification time of any worker in the work chain. """ # Bottom out on sample, info or tags if worker_name=='sample' or worker_name...
python
def _work_chain_mod_time(self, worker_name): """ Internal: We compute a modification time of a work chain. Returns: The newest modification time of any worker in the work chain. """ # Bottom out on sample, info or tags if worker_name=='sample' or worker_name...
[ "def", "_work_chain_mod_time", "(", "self", ",", "worker_name", ")", ":", "# Bottom out on sample, info or tags", "if", "worker_name", "==", "'sample'", "or", "worker_name", "==", "'info'", "or", "worker_name", "==", "'tags'", ":", "return", "datetime", ".", "dateti...
Internal: We compute a modification time of a work chain. Returns: The newest modification time of any worker in the work chain.
[ "Internal", ":", "We", "compute", "a", "modification", "time", "of", "a", "work", "chain", ".", "Returns", ":", "The", "newest", "modification", "time", "of", "any", "worker", "in", "the", "work", "chain", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L766-L784
SuperCowPowers/workbench
workbench/server/workbench_server.py
WorkBench._recursive_work_resolver
def _recursive_work_resolver(self, worker_name, md5): """ Internal: Input dependencies are recursively backtracked, invoked and then passed down the pipeline until getting to the requested worker. """ # Looking for the sample? if worker_name == 'sample': return self.g...
python
def _recursive_work_resolver(self, worker_name, md5): """ Internal: Input dependencies are recursively backtracked, invoked and then passed down the pipeline until getting to the requested worker. """ # Looking for the sample? if worker_name == 'sample': return self.g...
[ "def", "_recursive_work_resolver", "(", "self", ",", "worker_name", ",", "md5", ")", ":", "# Looking for the sample?", "if", "worker_name", "==", "'sample'", ":", "return", "self", ".", "get_sample", "(", "md5", ")", "# Looking for info?", "if", "worker_name", "==...
Internal: Input dependencies are recursively backtracked, invoked and then passed down the pipeline until getting to the requested worker.
[ "Internal", ":", "Input", "dependencies", "are", "recursively", "backtracked", "invoked", "and", "then", "passed", "down", "the", "pipeline", "until", "getting", "to", "the", "requested", "worker", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L786-L836
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.load_sample
def load_sample(self, file_path, tags=None): """Load a sample (or samples) into workbench Args: file_path: path to a file or directory tags (optional): a list of tags for the sample/samples ['bad','aptz13'] Returns: The list of md5s for all...
python
def load_sample(self, file_path, tags=None): """Load a sample (or samples) into workbench Args: file_path: path to a file or directory tags (optional): a list of tags for the sample/samples ['bad','aptz13'] Returns: The list of md5s for all...
[ "def", "load_sample", "(", "self", ",", "file_path", ",", "tags", "=", "None", ")", ":", "# Recommend a tag", "if", "not", "tags", ":", "print", "'\\n%sRequired: Add a list of tags when you load samples (put \\'unknown\\' if you must). \\\n \\n\\t%sExamples: [\\...
Load a sample (or samples) into workbench Args: file_path: path to a file or directory tags (optional): a list of tags for the sample/samples ['bad','aptz13'] Returns: The list of md5s for all samples
[ "Load", "a", "sample", "(", "or", "samples", ")", "into", "workbench", "Args", ":", "file_path", ":", "path", "to", "a", "file", "or", "directory", "tags", "(", "optional", ")", ":", "a", "list", "of", "tags", "for", "the", "sample", "/", "samples", ...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L89-L133
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.pivot
def pivot(self, md5, tag=''): """Pivot on an md5 (md5 can be a single sample or a sample_set) Args: md5: The md5 can be a single sample or a sample_set tags (optional): a tag for the sample (for the prompt) Returns: Nothing but it's sets th...
python
def pivot(self, md5, tag=''): """Pivot on an md5 (md5 can be a single sample or a sample_set) Args: md5: The md5 can be a single sample or a sample_set tags (optional): a tag for the sample (for the prompt) Returns: Nothing but it's sets th...
[ "def", "pivot", "(", "self", ",", "md5", ",", "tag", "=", "''", ")", ":", "# Is the md5 a tag?", "ss", "=", "self", ".", "workbench", ".", "generate_sample_set", "(", "md5", ")", "if", "ss", ":", "tag", "=", "md5", "if", "not", "tag", "else", "tag", ...
Pivot on an md5 (md5 can be a single sample or a sample_set) Args: md5: The md5 can be a single sample or a sample_set tags (optional): a tag for the sample (for the prompt) Returns: Nothing but it's sets the active sample/sample_set
[ "Pivot", "on", "an", "md5", "(", "md5", "can", "be", "a", "single", "sample", "or", "a", "sample_set", ")", "Args", ":", "md5", ":", "The", "md5", "can", "be", "a", "single", "sample", "or", "a", "sample_set", "tags", "(", "optional", ")", ":", "a"...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L135-L167
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.tags
def tags(self): '''Display tag information for all samples in database''' tags = self.workbench.get_all_tags() if not tags: return tag_df = pd.DataFrame(tags) tag_df = self.vectorize(tag_df, 'tags') print '\n%sSamples in Database%s' % (color.LightPurple, color...
python
def tags(self): '''Display tag information for all samples in database''' tags = self.workbench.get_all_tags() if not tags: return tag_df = pd.DataFrame(tags) tag_df = self.vectorize(tag_df, 'tags') print '\n%sSamples in Database%s' % (color.LightPurple, color...
[ "def", "tags", "(", "self", ")", ":", "tags", "=", "self", ".", "workbench", ".", "get_all_tags", "(", ")", "if", "not", "tags", ":", "return", "tag_df", "=", "pd", ".", "DataFrame", "(", "tags", ")", "tag_df", "=", "self", ".", "vectorize", "(", "...
Display tag information for all samples in database
[ "Display", "tag", "information", "for", "all", "samples", "in", "database" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L169-L177
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.pull_df
def pull_df(self, md5): """Wrapper for the Workbench get_dataframe method Args: md5: pull the dataframe identified by this md5 Returns: The uncompressed/unserialized dataframe """ try: _packed_df = self.workbench.get_dataframe(m...
python
def pull_df(self, md5): """Wrapper for the Workbench get_dataframe method Args: md5: pull the dataframe identified by this md5 Returns: The uncompressed/unserialized dataframe """ try: _packed_df = self.workbench.get_dataframe(m...
[ "def", "pull_df", "(", "self", ",", "md5", ")", ":", "try", ":", "_packed_df", "=", "self", ".", "workbench", ".", "get_dataframe", "(", "md5", ")", "_df", "=", "pd", ".", "read_msgpack", "(", "lz4", ".", "loads", "(", "_packed_df", ")", ")", "return...
Wrapper for the Workbench get_dataframe method Args: md5: pull the dataframe identified by this md5 Returns: The uncompressed/unserialized dataframe
[ "Wrapper", "for", "the", "Workbench", "get_dataframe", "method", "Args", ":", "md5", ":", "pull", "the", "dataframe", "identified", "by", "this", "md5", "Returns", ":", "The", "uncompressed", "/", "unserialized", "dataframe" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L179-L191
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.vectorize
def vectorize(self, df, column_name): """Vectorize a column in the dataframe""" vec_df = df[column_name].str.join(sep='-').str.get_dummies(sep='-') return vec_df
python
def vectorize(self, df, column_name): """Vectorize a column in the dataframe""" vec_df = df[column_name].str.join(sep='-').str.get_dummies(sep='-') return vec_df
[ "def", "vectorize", "(", "self", ",", "df", ",", "column_name", ")", ":", "vec_df", "=", "df", "[", "column_name", "]", ".", "str", ".", "join", "(", "sep", "=", "'-'", ")", ".", "str", ".", "get_dummies", "(", "sep", "=", "'-'", ")", "return", "...
Vectorize a column in the dataframe
[ "Vectorize", "a", "column", "in", "the", "dataframe" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L193-L196
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.flatten
def flatten(self, df, column_name): """Flatten a column in the dataframe that contains lists""" _exp_list = [[md5, x] for md5, value_list in zip(df['md5'], df[column_name]) for x in value_list] return pd.DataFrame(_exp_list, columns=['md5',column_name])
python
def flatten(self, df, column_name): """Flatten a column in the dataframe that contains lists""" _exp_list = [[md5, x] for md5, value_list in zip(df['md5'], df[column_name]) for x in value_list] return pd.DataFrame(_exp_list, columns=['md5',column_name])
[ "def", "flatten", "(", "self", ",", "df", ",", "column_name", ")", ":", "_exp_list", "=", "[", "[", "md5", ",", "x", "]", "for", "md5", ",", "value_list", "in", "zip", "(", "df", "[", "'md5'", "]", ",", "df", "[", "column_name", "]", ")", "for", ...
Flatten a column in the dataframe that contains lists
[ "Flatten", "a", "column", "in", "the", "dataframe", "that", "contains", "lists" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L198-L201
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.top_corr
def top_corr(self, df): """Give aggregation counts and correlations""" tag_freq = df.sum() tag_freq.sort(ascending=False) corr = df.corr().fillna(1) corr_dict = corr.to_dict() for tag, count in tag_freq.iteritems(): print ' %s%s: %s%s%s (' % (color.Green, t...
python
def top_corr(self, df): """Give aggregation counts and correlations""" tag_freq = df.sum() tag_freq.sort(ascending=False) corr = df.corr().fillna(1) corr_dict = corr.to_dict() for tag, count in tag_freq.iteritems(): print ' %s%s: %s%s%s (' % (color.Green, t...
[ "def", "top_corr", "(", "self", ",", "df", ")", ":", "tag_freq", "=", "df", ".", "sum", "(", ")", "tag_freq", ".", "sort", "(", "ascending", "=", "False", ")", "corr", "=", "df", ".", "corr", "(", ")", ".", "fillna", "(", "1", ")", "corr_dict", ...
Give aggregation counts and correlations
[ "Give", "aggregation", "counts", "and", "correlations" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L203-L216
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.search
def search(self, tags=None): """Wrapper for the Workbench search method Args: tags: a single tag 'pcap' or a list of tags to search for ['bad','aptz13'] Returns: A sample_set that contains the md5s for all matching samples """ if isinstance...
python
def search(self, tags=None): """Wrapper for the Workbench search method Args: tags: a single tag 'pcap' or a list of tags to search for ['bad','aptz13'] Returns: A sample_set that contains the md5s for all matching samples """ if isinstance...
[ "def", "search", "(", "self", ",", "tags", "=", "None", ")", ":", "if", "isinstance", "(", "tags", ",", "str", ")", ":", "tags", "=", "[", "tags", "]", "return", "self", ".", "workbench", ".", "generate_sample_set", "(", "tags", ")" ]
Wrapper for the Workbench search method Args: tags: a single tag 'pcap' or a list of tags to search for ['bad','aptz13'] Returns: A sample_set that contains the md5s for all matching samples
[ "Wrapper", "for", "the", "Workbench", "search", "method", "Args", ":", "tags", ":", "a", "single", "tag", "pcap", "or", "a", "list", "of", "tags", "to", "search", "for", "[", "bad", "aptz13", "]", "Returns", ":", "A", "sample_set", "that", "contains", ...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L218-L227
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.versions
def versions(self): """Announce Versions of CLI and Server Args: None Returns: The running versions of both the CLI and the Workbench Server """ print '%s<<< Workbench CLI Version %s >>>%s' % (color.LightBlue, self.version, color.Normal) print self...
python
def versions(self): """Announce Versions of CLI and Server Args: None Returns: The running versions of both the CLI and the Workbench Server """ print '%s<<< Workbench CLI Version %s >>>%s' % (color.LightBlue, self.version, color.Normal) print self...
[ "def", "versions", "(", "self", ")", ":", "print", "'%s<<< Workbench CLI Version %s >>>%s'", "%", "(", "color", ".", "LightBlue", ",", "self", ".", "version", ",", "color", ".", "Normal", ")", "print", "self", ".", "workbench", ".", "help", "(", "'version'",...
Announce Versions of CLI and Server Args: None Returns: The running versions of both the CLI and the Workbench Server
[ "Announce", "Versions", "of", "CLI", "and", "Server", "Args", ":", "None", "Returns", ":", "The", "running", "versions", "of", "both", "the", "CLI", "and", "the", "Workbench", "Server" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L229-L236
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell.run
def run(self): ''' Running the workbench CLI ''' # Announce versions self.versions() # Sample/Tag info and Help self.tags() print '\n%s' % self.workbench.help('cli') # Now that we have the Workbench connection spun up, we register some stuff # with the ...
python
def run(self): ''' Running the workbench CLI ''' # Announce versions self.versions() # Sample/Tag info and Help self.tags() print '\n%s' % self.workbench.help('cli') # Now that we have the Workbench connection spun up, we register some stuff # with the ...
[ "def", "run", "(", "self", ")", ":", "# Announce versions", "self", ".", "versions", "(", ")", "# Sample/Tag info and Help", "self", ".", "tags", "(", ")", "print", "'\\n%s'", "%", "self", ".", "workbench", ".", "help", "(", "'cli'", ")", "# Now that we have...
Running the workbench CLI
[ "Running", "the", "workbench", "CLI" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L238-L274
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell._connect
def _connect(self, server_info): """Connect to the workbench server""" # First we do a temp connect with a short heartbeat _tmp_connect = zerorpc.Client(timeout=300, heartbeat=2) _tmp_connect.connect('tcp://'+server_info['server']+':'+server_info['port']) try: _tmp_c...
python
def _connect(self, server_info): """Connect to the workbench server""" # First we do a temp connect with a short heartbeat _tmp_connect = zerorpc.Client(timeout=300, heartbeat=2) _tmp_connect.connect('tcp://'+server_info['server']+':'+server_info['port']) try: _tmp_c...
[ "def", "_connect", "(", "self", ",", "server_info", ")", ":", "# First we do a temp connect with a short heartbeat", "_tmp_connect", "=", "zerorpc", ".", "Client", "(", "timeout", "=", "300", ",", "heartbeat", "=", "2", ")", "_tmp_connect", ".", "connect", "(", ...
Connect to the workbench server
[ "Connect", "to", "the", "workbench", "server" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L276-L296
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell._progress_print
def _progress_print(self, sent, total): """Progress print show the progress of the current upload with a neat progress bar Credits: http://redino.net/blog/2013/07/display-a-progress-bar-in-console-using-python/ """ percent = min(int(sent*100.0/total), 100) sys.stdout.write('\r...
python
def _progress_print(self, sent, total): """Progress print show the progress of the current upload with a neat progress bar Credits: http://redino.net/blog/2013/07/display-a-progress-bar-in-console-using-python/ """ percent = min(int(sent*100.0/total), 100) sys.stdout.write('\r...
[ "def", "_progress_print", "(", "self", ",", "sent", ",", "total", ")", ":", "percent", "=", "min", "(", "int", "(", "sent", "*", "100.0", "/", "total", ")", ",", "100", ")", "sys", ".", "stdout", ".", "write", "(", "'\\r{0}[{1}{2}] {3}{4}%{5}'", ".", ...
Progress print show the progress of the current upload with a neat progress bar Credits: http://redino.net/blog/2013/07/display-a-progress-bar-in-console-using-python/
[ "Progress", "print", "show", "the", "progress", "of", "the", "current", "upload", "with", "a", "neat", "progress", "bar", "Credits", ":", "http", ":", "//", "redino", ".", "net", "/", "blog", "/", "2013", "/", "07", "/", "display", "-", "a", "-", "pr...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L298-L305
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell._work_request
def _work_request(self, worker, md5=None): """Wrapper for a work_request to workbench""" # I'm sure there's a better way to do this if not md5 and not self.session.md5: return 'Must call worker with an md5 argument...' elif not md5: md5 = self.session.md5 ...
python
def _work_request(self, worker, md5=None): """Wrapper for a work_request to workbench""" # I'm sure there's a better way to do this if not md5 and not self.session.md5: return 'Must call worker with an md5 argument...' elif not md5: md5 = self.session.md5 ...
[ "def", "_work_request", "(", "self", ",", "worker", ",", "md5", "=", "None", ")", ":", "# I'm sure there's a better way to do this", "if", "not", "md5", "and", "not", "self", ".", "session", ".", "md5", ":", "return", "'Must call worker with an md5 argument...'", ...
Wrapper for a work_request to workbench
[ "Wrapper", "for", "a", "work_request", "to", "workbench" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L307-L324
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell._generate_command_dict
def _generate_command_dict(self): """Create a customized namespace for Workbench with a bunch of shortcuts and helper/alias functions that will make using the shell MUCH easier. """ # First add all the workers commands = {} for worker in self.workbench.list_all_worke...
python
def _generate_command_dict(self): """Create a customized namespace for Workbench with a bunch of shortcuts and helper/alias functions that will make using the shell MUCH easier. """ # First add all the workers commands = {} for worker in self.workbench.list_all_worke...
[ "def", "_generate_command_dict", "(", "self", ")", ":", "# First add all the workers", "commands", "=", "{", "}", "for", "worker", "in", "self", ".", "workbench", ".", "list_all_workers", "(", ")", ":", "commands", "[", "worker", "]", "=", "lambda", "md5", "...
Create a customized namespace for Workbench with a bunch of shortcuts and helper/alias functions that will make using the shell MUCH easier.
[ "Create", "a", "customized", "namespace", "for", "Workbench", "with", "a", "bunch", "of", "shortcuts", "and", "helper", "/", "alias", "functions", "that", "will", "make", "using", "the", "shell", "MUCH", "easier", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L330-L367
SuperCowPowers/workbench
workbench_apps/workbench_cli/workbench_shell.py
WorkbenchShell._register_info
def _register_info(self): """Register local methods in the Workbench Information system""" # Stores information on Workbench commands and signatures for name, meth in inspect.getmembers(self, predicate=inspect.isroutine): if not name.startswith('_') and name != 'run': ...
python
def _register_info(self): """Register local methods in the Workbench Information system""" # Stores information on Workbench commands and signatures for name, meth in inspect.getmembers(self, predicate=inspect.isroutine): if not name.startswith('_') and name != 'run': ...
[ "def", "_register_info", "(", "self", ")", ":", "# Stores information on Workbench commands and signatures", "for", "name", ",", "meth", "in", "inspect", ".", "getmembers", "(", "self", ",", "predicate", "=", "inspect", ".", "isroutine", ")", ":", "if", "not", "...
Register local methods in the Workbench Information system
[ "Register", "local", "methods", "in", "the", "Workbench", "Information", "system" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L390-L404
SuperCowPowers/workbench
workbench_apps/workbench_cli/auto_quote_xform.py
AutoQuoteTransformer.transform
def transform(self, line, _continue_prompt): """Shortcut Workbench commands by using 'auto-quotes'""" # Capture the original line orig_line = line # Get tokens from all the currently active namespace ns_token_set = set([token for nspace in self.shell.all_ns_refs for token in ns...
python
def transform(self, line, _continue_prompt): """Shortcut Workbench commands by using 'auto-quotes'""" # Capture the original line orig_line = line # Get tokens from all the currently active namespace ns_token_set = set([token for nspace in self.shell.all_ns_refs for token in ns...
[ "def", "transform", "(", "self", ",", "line", ",", "_continue_prompt", ")", ":", "# Capture the original line", "orig_line", "=", "line", "# Get tokens from all the currently active namespace", "ns_token_set", "=", "set", "(", "[", "token", "for", "nspace", "in", "sel...
Shortcut Workbench commands by using 'auto-quotes
[ "Shortcut", "Workbench", "commands", "by", "using", "auto", "-", "quotes" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/auto_quote_xform.py#L16-L78
yfpeng/bioc
bioc/biocxml/decoder.py
BioCXMLDecoder.decodes
def decodes(self, s: str) -> BioCCollection: """ Deserialize ``s`` to a BioC collection object. Args: s: a "str" instance containing a BioC collection Returns: an object of BioCollection """ tree = etree.parse(io.BytesIO(bytes(s, encoding='UTF-8'...
python
def decodes(self, s: str) -> BioCCollection: """ Deserialize ``s`` to a BioC collection object. Args: s: a "str" instance containing a BioC collection Returns: an object of BioCollection """ tree = etree.parse(io.BytesIO(bytes(s, encoding='UTF-8'...
[ "def", "decodes", "(", "self", ",", "s", ":", "str", ")", "->", "BioCCollection", ":", "tree", "=", "etree", ".", "parse", "(", "io", ".", "BytesIO", "(", "bytes", "(", "s", ",", "encoding", "=", "'UTF-8'", ")", ")", ")", "collection", "=", "self",...
Deserialize ``s`` to a BioC collection object. Args: s: a "str" instance containing a BioC collection Returns: an object of BioCollection
[ "Deserialize", "s", "to", "a", "BioC", "collection", "object", "." ]
train
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocxml/decoder.py#L22-L37
yfpeng/bioc
bioc/biocxml/decoder.py
BioCXMLDecoder.decode
def decode(self, fp: TextIO) -> BioCCollection: """ Deserialize ``fp`` to a BioC collection object. Args: fp: a ``.read()``-supporting file-like object containing a BioC collection Returns: an object of BioCollection """ # utf8_parser = etree.XML...
python
def decode(self, fp: TextIO) -> BioCCollection: """ Deserialize ``fp`` to a BioC collection object. Args: fp: a ``.read()``-supporting file-like object containing a BioC collection Returns: an object of BioCollection """ # utf8_parser = etree.XML...
[ "def", "decode", "(", "self", ",", "fp", ":", "TextIO", ")", "->", "BioCCollection", ":", "# utf8_parser = etree.XMLParser(encoding='utf-8')", "tree", "=", "etree", ".", "parse", "(", "fp", ")", "collection", "=", "self", ".", "__parse_collection", "(", "tree", ...
Deserialize ``fp`` to a BioC collection object. Args: fp: a ``.read()``-supporting file-like object containing a BioC collection Returns: an object of BioCollection
[ "Deserialize", "fp", "to", "a", "BioC", "collection", "object", "." ]
train
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocxml/decoder.py#L39-L55
SuperCowPowers/workbench
workbench/clients/upload_file.py
run
def run(): """This client pushes a file into Workbench.""" # Grab server args args = client_helper.grab_server_args() # Start up workbench connection workbench = zerorpc.Client(timeout=300, heartbeat=60) workbench.connect('tcp://'+args['server']+':'+args['port']) # Upload the file int...
python
def run(): """This client pushes a file into Workbench.""" # Grab server args args = client_helper.grab_server_args() # Start up workbench connection workbench = zerorpc.Client(timeout=300, heartbeat=60) workbench.connect('tcp://'+args['server']+':'+args['port']) # Upload the file int...
[ "def", "run", "(", ")", ":", "# Grab server args", "args", "=", "client_helper", ".", "grab_server_args", "(", ")", "# Start up workbench connection", "workbench", "=", "zerorpc", ".", "Client", "(", "timeout", "=", "300", ",", "heartbeat", "=", "60", ")", "wo...
This client pushes a file into Workbench.
[ "This", "client", "pushes", "a", "file", "into", "Workbench", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/upload_file.py#L8-L29
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
RekallAdapter.execute
def execute(self, input_data): ''' Execute method ''' # Grab the raw bytes of the sample raw_bytes = input_data['sample']['raw_bytes'] # Spin up the rekall session and render components session = MemSession(raw_bytes) renderer = WorkbenchRenderer(session=session) ...
python
def execute(self, input_data): ''' Execute method ''' # Grab the raw bytes of the sample raw_bytes = input_data['sample']['raw_bytes'] # Spin up the rekall session and render components session = MemSession(raw_bytes) renderer = WorkbenchRenderer(session=session) ...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "# Grab the raw bytes of the sample", "raw_bytes", "=", "input_data", "[", "'sample'", "]", "[", "'raw_bytes'", "]", "# Spin up the rekall session and render components", "session", "=", "MemSession", "(", "raw...
Execute method
[ "Execute", "method" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L43-L56
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
RekallAdapter.process_row
def process_row(cls, data, column_map): """Process the row data from Rekall""" row = {} for key,value in data.iteritems(): if not value: value = '-' elif isinstance(value, list): value = value[1] elif isinstance(...
python
def process_row(cls, data, column_map): """Process the row data from Rekall""" row = {} for key,value in data.iteritems(): if not value: value = '-' elif isinstance(value, list): value = value[1] elif isinstance(...
[ "def", "process_row", "(", "cls", ",", "data", ",", "column_map", ")", ":", "row", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "iteritems", "(", ")", ":", "if", "not", "value", ":", "value", "=", "'-'", "elif", "isinstance", "(", ...
Process the row data from Rekall
[ "Process", "the", "row", "data", "from", "Rekall" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L59-L76
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
WorkbenchRenderer.start
def start(self, plugin_name=None, kwargs=None): """Start method: initial data structures and store some meta data.""" self.output = [] # Start basically resets the output data super(WorkbenchRenderer, self).start(plugin_name=plugin_name) return self
python
def start(self, plugin_name=None, kwargs=None): """Start method: initial data structures and store some meta data.""" self.output = [] # Start basically resets the output data super(WorkbenchRenderer, self).start(plugin_name=plugin_name) return self
[ "def", "start", "(", "self", ",", "plugin_name", "=", "None", ",", "kwargs", "=", "None", ")", ":", "self", ".", "output", "=", "[", "]", "# Start basically resets the output data", "super", "(", "WorkbenchRenderer", ",", "self", ")", ".", "start", "(", "p...
Start method: initial data structures and store some meta data.
[ "Start", "method", ":", "initial", "data", "structures", "and", "store", "some", "meta", "data", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L116-L120
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
WorkbenchRenderer.format
def format(self, formatstring, *args): """Presentation Information from the Plugin""" # Make a new section if self.incoming_section: self.SendMessage(['s', {'name': args}]) self.incoming_section = False
python
def format(self, formatstring, *args): """Presentation Information from the Plugin""" # Make a new section if self.incoming_section: self.SendMessage(['s', {'name': args}]) self.incoming_section = False
[ "def", "format", "(", "self", ",", "formatstring", ",", "*", "args", ")", ":", "# Make a new section", "if", "self", ".", "incoming_section", ":", "self", ".", "SendMessage", "(", "[", "'s'", ",", "{", "'name'", ":", "args", "}", "]", ")", "self", ".",...
Presentation Information from the Plugin
[ "Presentation", "Information", "from", "the", "Plugin" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L122-L128
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
WorkbenchRenderer.SendMessage
def SendMessage(self, statement): """Here we're actually capturing messages and putting them into our output""" # The way messages are 'encapsulated' by Rekall is questionable, 99% of the # time it's way better to have a dictionary...shrug... message_type = statement[0] ...
python
def SendMessage(self, statement): """Here we're actually capturing messages and putting them into our output""" # The way messages are 'encapsulated' by Rekall is questionable, 99% of the # time it's way better to have a dictionary...shrug... message_type = statement[0] ...
[ "def", "SendMessage", "(", "self", ",", "statement", ")", ":", "# The way messages are 'encapsulated' by Rekall is questionable, 99% of the", "# time it's way better to have a dictionary...shrug...", "message_type", "=", "statement", "[", "0", "]", "message_data", "=", "statement...
Here we're actually capturing messages and putting them into our output
[ "Here", "we", "re", "actually", "capturing", "messages", "and", "putting", "them", "into", "our", "output" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L138-L145
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
WorkbenchRenderer.open
def open(self, directory=None, filename=None, mode="rb"): """Opens a file for writing or reading.""" path = os.path.join(directory, filename) return open(path, mode)
python
def open(self, directory=None, filename=None, mode="rb"): """Opens a file for writing or reading.""" path = os.path.join(directory, filename) return open(path, mode)
[ "def", "open", "(", "self", ",", "directory", "=", "None", ",", "filename", "=", "None", ",", "mode", "=", "\"rb\"", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "filename", ")", "return", "open", "(", "path", ",", ...
Opens a file for writing or reading.
[ "Opens", "a", "file", "for", "writing", "or", "reading", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L147-L150
SuperCowPowers/workbench
workbench_apps/workbench_cli/file_streamer.py
FileStreamer._file_chunks
def _file_chunks(self, data, chunk_size): """ Yield compressed chunks from a data array""" for i in xrange(0, len(data), chunk_size): yield self.compressor(data[i:i+chunk_size])
python
def _file_chunks(self, data, chunk_size): """ Yield compressed chunks from a data array""" for i in xrange(0, len(data), chunk_size): yield self.compressor(data[i:i+chunk_size])
[ "def", "_file_chunks", "(", "self", ",", "data", ",", "chunk_size", ")", ":", "for", "i", "in", "xrange", "(", "0", ",", "len", "(", "data", ")", ",", "chunk_size", ")", ":", "yield", "self", ".", "compressor", "(", "data", "[", "i", ":", "i", "+...
Yield compressed chunks from a data array
[ "Yield", "compressed", "chunks", "from", "a", "data", "array" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/file_streamer.py#L24-L27
SuperCowPowers/workbench
workbench_apps/workbench_cli/file_streamer.py
FileStreamer.stream_to_workbench
def stream_to_workbench(self, raw_bytes, filename, type_tag, tags): """Split up a large file into chunks and send to Workbench""" md5_list = [] sent_bytes = 0 total_bytes = len(raw_bytes) for chunk in self._file_chunks(raw_bytes, self.chunk_size): md5_list.append(self...
python
def stream_to_workbench(self, raw_bytes, filename, type_tag, tags): """Split up a large file into chunks and send to Workbench""" md5_list = [] sent_bytes = 0 total_bytes = len(raw_bytes) for chunk in self._file_chunks(raw_bytes, self.chunk_size): md5_list.append(self...
[ "def", "stream_to_workbench", "(", "self", ",", "raw_bytes", ",", "filename", ",", "type_tag", ",", "tags", ")", ":", "md5_list", "=", "[", "]", "sent_bytes", "=", "0", "total_bytes", "=", "len", "(", "raw_bytes", ")", "for", "chunk", "in", "self", ".", ...
Split up a large file into chunks and send to Workbench
[ "Split", "up", "a", "large", "file", "into", "chunks", "and", "send", "to", "Workbench" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/file_streamer.py#L29-L46
yfpeng/bioc
bioc/biocjson/encoder.py
dumps
def dumps(obj, **kwargs) -> str: """ Serialize a BioC ``obj`` to a JSON formatted ``str``. """ return json.dumps(obj, cls=BioCJSONEncoder, **kwargs)
python
def dumps(obj, **kwargs) -> str: """ Serialize a BioC ``obj`` to a JSON formatted ``str``. """ return json.dumps(obj, cls=BioCJSONEncoder, **kwargs)
[ "def", "dumps", "(", "obj", ",", "*", "*", "kwargs", ")", "->", "str", ":", "return", "json", ".", "dumps", "(", "obj", ",", "cls", "=", "BioCJSONEncoder", ",", "*", "*", "kwargs", ")" ]
Serialize a BioC ``obj`` to a JSON formatted ``str``.
[ "Serialize", "a", "BioC", "obj", "to", "a", "JSON", "formatted", "str", "." ]
train
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/encoder.py#L14-L18
yfpeng/bioc
bioc/biocjson/encoder.py
dump
def dump(obj, fp, **kwargs): """ Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object) """ return json.dump(obj, fp, cls=BioCJSONEncoder, **kwargs)
python
def dump(obj, fp, **kwargs): """ Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object) """ return json.dump(obj, fp, cls=BioCJSONEncoder, **kwargs)
[ "def", "dump", "(", "obj", ",", "fp", ",", "*", "*", "kwargs", ")", ":", "return", "json", ".", "dump", "(", "obj", ",", "fp", ",", "cls", "=", "BioCJSONEncoder", ",", "*", "*", "kwargs", ")" ]
Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object)
[ "Serialize", "obj", "as", "a", "JSON", "formatted", "stream", "to", "fp", "(", "a", ".", "write", "()", "-", "supporting", "file", "-", "like", "object", ")" ]
train
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/encoder.py#L21-L25
yfpeng/bioc
bioc/biocjson/encoder.py
BioCJsonIterWriter.write
def write(self, obj: BioCDocument or BioCPassage or BioCSentence): """ Encode and write a single object. Args: obj: an instance of BioCDocument, BioCPassage, or BioCSentence Returns: """ if self.level == DOCUMENT and not isinstance(obj, BioCDocument): ...
python
def write(self, obj: BioCDocument or BioCPassage or BioCSentence): """ Encode and write a single object. Args: obj: an instance of BioCDocument, BioCPassage, or BioCSentence Returns: """ if self.level == DOCUMENT and not isinstance(obj, BioCDocument): ...
[ "def", "write", "(", "self", ",", "obj", ":", "BioCDocument", "or", "BioCPassage", "or", "BioCSentence", ")", ":", "if", "self", ".", "level", "==", "DOCUMENT", "and", "not", "isinstance", "(", "obj", ",", "BioCDocument", ")", ":", "raise", "ValueError", ...
Encode and write a single object. Args: obj: an instance of BioCDocument, BioCPassage, or BioCSentence Returns:
[ "Encode", "and", "write", "a", "single", "object", "." ]
train
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/encoder.py#L106-L122
SuperCowPowers/workbench
workbench/workers/mem_connscan.py
MemoryImageConnScan.execute
def execute(self, input_data): ''' Execute method ''' # Spin up the rekall adapter adapter = RekallAdapter() adapter.set_plugin_name(self.plugin_name) rekall_output = adapter.execute(input_data) # Process the output data for line in rekall_output: i...
python
def execute(self, input_data): ''' Execute method ''' # Spin up the rekall adapter adapter = RekallAdapter() adapter.set_plugin_name(self.plugin_name) rekall_output = adapter.execute(input_data) # Process the output data for line in rekall_output: i...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "# Spin up the rekall adapter", "adapter", "=", "RekallAdapter", "(", ")", "adapter", ".", "set_plugin_name", "(", "self", ".", "plugin_name", ")", "rekall_output", "=", "adapter", ".", "execute", "(", ...
Execute method
[ "Execute", "method" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/mem_connscan.py#L23-L49
SuperCowPowers/workbench
workbench/workers/view_memory_deep.py
ViewMemoryDeep.execute
def execute(self, input_data): ''' Execute the ViewMemoryDeep worker ''' # Aggregate the output from all the memory workers, clearly this could be kewler output = input_data['view_memory'] output['tables'] = {} for data in [input_data[key] for key in ViewMemoryDeep.dependencies]...
python
def execute(self, input_data): ''' Execute the ViewMemoryDeep worker ''' # Aggregate the output from all the memory workers, clearly this could be kewler output = input_data['view_memory'] output['tables'] = {} for data in [input_data[key] for key in ViewMemoryDeep.dependencies]...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "# Aggregate the output from all the memory workers, clearly this could be kewler", "output", "=", "input_data", "[", "'view_memory'", "]", "output", "[", "'tables'", "]", "=", "{", "}", "for", "data", "in", ...
Execute the ViewMemoryDeep worker
[ "Execute", "the", "ViewMemoryDeep", "worker" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_memory_deep.py#L11-L20
SuperCowPowers/workbench
workbench/workers/view_memory.py
ViewMemory.execute
def execute(self, input_data): ''' Execute the ViewMemory worker ''' # Aggregate the output from all the memory workers into concise summary info output = {'meta': input_data['mem_meta']['tables']['info']} output['connscan'] = list(set([item['Remote Address'] for item in input_data['mem...
python
def execute(self, input_data): ''' Execute the ViewMemory worker ''' # Aggregate the output from all the memory workers into concise summary info output = {'meta': input_data['mem_meta']['tables']['info']} output['connscan'] = list(set([item['Remote Address'] for item in input_data['mem...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "# Aggregate the output from all the memory workers into concise summary info", "output", "=", "{", "'meta'", ":", "input_data", "[", "'mem_meta'", "]", "[", "'tables'", "]", "[", "'info'", "]", "}", "outpu...
Execute the ViewMemory worker
[ "Execute", "the", "ViewMemory", "worker" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_memory.py#L12-L21
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaConfig.store
def store(self, name, value, atype, new_name=None, multiplier=None, allowed_values=None): ''' store a config value in a dictionary, these values are used to populate a trasnfer spec validation -- check type, check allowed values and rename if required ''' if value is not None: _b...
python
def store(self, name, value, atype, new_name=None, multiplier=None, allowed_values=None): ''' store a config value in a dictionary, these values are used to populate a trasnfer spec validation -- check type, check allowed values and rename if required ''' if value is not None: _b...
[ "def", "store", "(", "self", ",", "name", ",", "value", ",", "atype", ",", "new_name", "=", "None", ",", "multiplier", "=", "None", ",", "allowed_values", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "_bad_type", "=", "(", "not", ...
store a config value in a dictionary, these values are used to populate a trasnfer spec validation -- check type, check allowed values and rename if required
[ "store", "a", "config", "value", "in", "a", "dictionary", "these", "values", "are", "used", "to", "populate", "a", "trasnfer", "spec", "validation", "--", "check", "type", "check", "allowed", "values", "and", "rename", "if", "required" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L133-L160
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaConfig.multi_session
def multi_session(self): ''' convert the multi_session param a number ''' _val = 0 if "multi_session" in self._dict: _val = self._dict["multi_session"] if str(_val).lower() == 'all': _val = -1 return int(_val)
python
def multi_session(self): ''' convert the multi_session param a number ''' _val = 0 if "multi_session" in self._dict: _val = self._dict["multi_session"] if str(_val).lower() == 'all': _val = -1 return int(_val)
[ "def", "multi_session", "(", "self", ")", ":", "_val", "=", "0", "if", "\"multi_session\"", "in", "self", ".", "_dict", ":", "_val", "=", "self", ".", "_dict", "[", "\"multi_session\"", "]", "if", "str", "(", "_val", ")", ".", "lower", "(", ")", "=="...
convert the multi_session param a number
[ "convert", "the", "multi_session", "param", "a", "number" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L168-L176
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager._raw_aspera_metadata
def _raw_aspera_metadata(self, bucket): ''' get the Aspera connection details on Aspera enabled buckets ''' response = self._client.get_bucket_aspera(Bucket=bucket) # Parse metadata from response aspera_access_key = response['AccessKey']['Id'] aspera_secret_key = response['Acces...
python
def _raw_aspera_metadata(self, bucket): ''' get the Aspera connection details on Aspera enabled buckets ''' response = self._client.get_bucket_aspera(Bucket=bucket) # Parse metadata from response aspera_access_key = response['AccessKey']['Id'] aspera_secret_key = response['Acces...
[ "def", "_raw_aspera_metadata", "(", "self", ",", "bucket", ")", ":", "response", "=", "self", ".", "_client", ".", "get_bucket_aspera", "(", "Bucket", "=", "bucket", ")", "# Parse metadata from response", "aspera_access_key", "=", "response", "[", "'AccessKey'", "...
get the Aspera connection details on Aspera enabled buckets
[ "get", "the", "Aspera", "connection", "details", "on", "Aspera", "enabled", "buckets" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L245-L254
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager._fetch_transfer_spec
def _fetch_transfer_spec(self, node_action, token, bucket_name, paths): ''' make hhtp call to Aspera to fetch back trasnfer spec ''' aspera_access_key, aspera_secret_key, ats_endpoint = self._get_aspera_metadata(bucket_name) _headers = {'accept': "application/json", 'Content...
python
def _fetch_transfer_spec(self, node_action, token, bucket_name, paths): ''' make hhtp call to Aspera to fetch back trasnfer spec ''' aspera_access_key, aspera_secret_key, ats_endpoint = self._get_aspera_metadata(bucket_name) _headers = {'accept': "application/json", 'Content...
[ "def", "_fetch_transfer_spec", "(", "self", ",", "node_action", ",", "token", ",", "bucket_name", ",", "paths", ")", ":", "aspera_access_key", ",", "aspera_secret_key", ",", "ats_endpoint", "=", "self", ".", "_get_aspera_metadata", "(", "bucket_name", ")", "_heade...
make hhtp call to Aspera to fetch back trasnfer spec
[ "make", "hhtp", "call", "to", "Aspera", "to", "fetch", "back", "trasnfer", "spec" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L256-L276
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager._create_transfer_spec
def _create_transfer_spec(self, call_args): ''' pass the transfer details to aspera and receive back a populated transfer spec complete with access token ''' _paths = [] for _file_pair in call_args.file_pair_list: _path = OrderedDict() if call_args.direction =...
python
def _create_transfer_spec(self, call_args): ''' pass the transfer details to aspera and receive back a populated transfer spec complete with access token ''' _paths = [] for _file_pair in call_args.file_pair_list: _path = OrderedDict() if call_args.direction =...
[ "def", "_create_transfer_spec", "(", "self", ",", "call_args", ")", ":", "_paths", "=", "[", "]", "for", "_file_pair", "in", "call_args", ".", "file_pair_list", ":", "_path", "=", "OrderedDict", "(", ")", "if", "call_args", ".", "direction", "==", "enumAsper...
pass the transfer details to aspera and receive back a populated transfer spec complete with access token
[ "pass", "the", "transfer", "details", "to", "aspera", "and", "receive", "back", "a", "populated", "transfer", "spec", "complete", "with", "access", "token" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L278-L314
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager.upload_directory
def upload_directory(self, directory, bucket, key, transfer_config=None, subscribers=None): ''' upload a directory using Aspera ''' check_io_access(directory, os.R_OK) return self._queue_task(bucket, [FilePair(key, directory)], transfer_config, subscribers, enumAs...
python
def upload_directory(self, directory, bucket, key, transfer_config=None, subscribers=None): ''' upload a directory using Aspera ''' check_io_access(directory, os.R_OK) return self._queue_task(bucket, [FilePair(key, directory)], transfer_config, subscribers, enumAs...
[ "def", "upload_directory", "(", "self", ",", "directory", ",", "bucket", ",", "key", ",", "transfer_config", "=", "None", ",", "subscribers", "=", "None", ")", ":", "check_io_access", "(", "directory", ",", "os", ".", "R_OK", ")", "return", "self", ".", ...
upload a directory using Aspera
[ "upload", "a", "directory", "using", "Aspera" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L316-L320
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager.download_directory
def download_directory(self, bucket, key, directory, transfer_config=None, subscribers=None): ''' download a directory using Aspera ''' check_io_access(directory, os.W_OK) return self._queue_task(bucket, [FilePair(key, directory)], transfer_config, subscribers, en...
python
def download_directory(self, bucket, key, directory, transfer_config=None, subscribers=None): ''' download a directory using Aspera ''' check_io_access(directory, os.W_OK) return self._queue_task(bucket, [FilePair(key, directory)], transfer_config, subscribers, en...
[ "def", "download_directory", "(", "self", ",", "bucket", ",", "key", ",", "directory", ",", "transfer_config", "=", "None", ",", "subscribers", "=", "None", ")", ":", "check_io_access", "(", "directory", ",", "os", ".", "W_OK", ")", "return", "self", ".", ...
download a directory using Aspera
[ "download", "a", "directory", "using", "Aspera" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L322-L326
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager.upload
def upload(self, fileobj, bucket, key, transfer_config=None, subscribers=None): ''' upload a file using Aspera ''' check_io_access(fileobj, os.R_OK, True) return self._queue_task(bucket, [FilePair(key, fileobj)], transfer_config, subscribers, enumAsperaDirection.S...
python
def upload(self, fileobj, bucket, key, transfer_config=None, subscribers=None): ''' upload a file using Aspera ''' check_io_access(fileobj, os.R_OK, True) return self._queue_task(bucket, [FilePair(key, fileobj)], transfer_config, subscribers, enumAsperaDirection.S...
[ "def", "upload", "(", "self", ",", "fileobj", ",", "bucket", ",", "key", ",", "transfer_config", "=", "None", ",", "subscribers", "=", "None", ")", ":", "check_io_access", "(", "fileobj", ",", "os", ".", "R_OK", ",", "True", ")", "return", "self", ".",...
upload a file using Aspera
[ "upload", "a", "file", "using", "Aspera" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L328-L332
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager.download
def download(self, bucket, key, fileobj, transfer_config=None, subscribers=None): ''' download a file using Aspera ''' check_io_access(os.path.dirname(fileobj), os.W_OK) return self._queue_task(bucket, [FilePair(key, fileobj)], transfer_config, subscribers, enumAs...
python
def download(self, bucket, key, fileobj, transfer_config=None, subscribers=None): ''' download a file using Aspera ''' check_io_access(os.path.dirname(fileobj), os.W_OK) return self._queue_task(bucket, [FilePair(key, fileobj)], transfer_config, subscribers, enumAs...
[ "def", "download", "(", "self", ",", "bucket", ",", "key", ",", "fileobj", ",", "transfer_config", "=", "None", ",", "subscribers", "=", "None", ")", ":", "check_io_access", "(", "os", ".", "path", ".", "dirname", "(", "fileobj", ")", ",", "os", ".", ...
download a file using Aspera
[ "download", "a", "file", "using", "Aspera" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L334-L338
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager.set_log_details
def set_log_details(aspera_log_path=None, sdk_log_level=logging.NOTSET): ''' set the aspera log path - used by th Ascp process set the internal aspera sdk activity - for debug purposes ''' if aspera_log_path: check_io_access(aspera_log_path, os.W_OK) ...
python
def set_log_details(aspera_log_path=None, sdk_log_level=logging.NOTSET): ''' set the aspera log path - used by th Ascp process set the internal aspera sdk activity - for debug purposes ''' if aspera_log_path: check_io_access(aspera_log_path, os.W_OK) ...
[ "def", "set_log_details", "(", "aspera_log_path", "=", "None", ",", "sdk_log_level", "=", "logging", ".", "NOTSET", ")", ":", "if", "aspera_log_path", ":", "check_io_access", "(", "aspera_log_path", ",", "os", ".", "W_OK", ")", "AsperaTransferCoordinator", ".", ...
set the aspera log path - used by th Ascp process set the internal aspera sdk activity - for debug purposes
[ "set", "the", "aspera", "log", "path", "-", "used", "by", "th", "Ascp", "process", "set", "the", "internal", "aspera", "sdk", "activity", "-", "for", "debug", "purposes" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L341-L356
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager._validate_args
def _validate_args(self, args): ''' validate the user arguments ''' assert(args.bucket) if args.subscribers: for _subscriber in args.subscribers: assert(isinstance(_subscriber, AsperaBaseSubscriber)) if (args.transfer_config): assert(isinstance(a...
python
def _validate_args(self, args): ''' validate the user arguments ''' assert(args.bucket) if args.subscribers: for _subscriber in args.subscribers: assert(isinstance(_subscriber, AsperaBaseSubscriber)) if (args.transfer_config): assert(isinstance(a...
[ "def", "_validate_args", "(", "self", ",", "args", ")", ":", "assert", "(", "args", ".", "bucket", ")", "if", "args", ".", "subscribers", ":", "for", "_subscriber", "in", "args", ".", "subscribers", ":", "assert", "(", "isinstance", "(", "_subscriber", "...
validate the user arguments
[ "validate", "the", "user", "arguments" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L358-L375
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager._queue_task
def _queue_task(self, bucket, file_pair_list, transfer_config, subscribers, direction): ''' queue the upload/download - when get processed when resources available Use class level transfer_config if not defined. ''' config = transfer_config if transfer_config else self._transfer_config ...
python
def _queue_task(self, bucket, file_pair_list, transfer_config, subscribers, direction): ''' queue the upload/download - when get processed when resources available Use class level transfer_config if not defined. ''' config = transfer_config if transfer_config else self._transfer_config ...
[ "def", "_queue_task", "(", "self", ",", "bucket", ",", "file_pair_list", ",", "transfer_config", ",", "subscribers", ",", "direction", ")", ":", "config", "=", "transfer_config", "if", "transfer_config", "else", "self", ".", "_transfer_config", "_call_args", "=", ...
queue the upload/download - when get processed when resources available Use class level transfer_config if not defined.
[ "queue", "the", "upload", "/", "download", "-", "when", "get", "processed", "when", "resources", "available", "Use", "class", "level", "transfer_config", "if", "not", "defined", "." ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L377-L392
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferManager._shutdown
def _shutdown(self, cancel, cancel_msg, exc_type=CancelledError): ''' Internal shutdown used by 'shutdown' method above ''' if cancel: # Cancel all in-flight transfers if requested, before waiting # for them to complete. self._coordinator_controller.cancel(cancel_msg...
python
def _shutdown(self, cancel, cancel_msg, exc_type=CancelledError): ''' Internal shutdown used by 'shutdown' method above ''' if cancel: # Cancel all in-flight transfers if requested, before waiting # for them to complete. self._coordinator_controller.cancel(cancel_msg...
[ "def", "_shutdown", "(", "self", ",", "cancel", ",", "cancel_msg", ",", "exc_type", "=", "CancelledError", ")", ":", "if", "cancel", ":", "# Cancel all in-flight transfers if requested, before waiting", "# for them to complete.", "self", ".", "_coordinator_controller", "....
Internal shutdown used by 'shutdown' method above
[ "Internal", "shutdown", "used", "by", "shutdown", "method", "above" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L431-L451
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferCoordinatorController.cleanup
def cleanup(self): ''' Stop backgroud thread and cleanup resources ''' self._processing_stop = True self._wakeup_processing_thread() self._processing_stopped_event.wait(3)
python
def cleanup(self): ''' Stop backgroud thread and cleanup resources ''' self._processing_stop = True self._wakeup_processing_thread() self._processing_stopped_event.wait(3)
[ "def", "cleanup", "(", "self", ")", ":", "self", ".", "_processing_stop", "=", "True", "self", ".", "_wakeup_processing_thread", "(", ")", "self", ".", "_processing_stopped_event", ".", "wait", "(", "3", ")" ]
Stop backgroud thread and cleanup resources
[ "Stop", "backgroud", "thread", "and", "cleanup", "resources" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L475-L479
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferCoordinatorController.tracked_coordinator_count
def tracked_coordinator_count(self, count_ascps=False): ''' count the number of cooridnators currently being processed or count the number of ascps currently being used ''' with self._lock: _count = 0 if count_ascps: for _coordinator in self._tracked_trans...
python
def tracked_coordinator_count(self, count_ascps=False): ''' count the number of cooridnators currently being processed or count the number of ascps currently being used ''' with self._lock: _count = 0 if count_ascps: for _coordinator in self._tracked_trans...
[ "def", "tracked_coordinator_count", "(", "self", ",", "count_ascps", "=", "False", ")", ":", "with", "self", ".", "_lock", ":", "_count", "=", "0", "if", "count_ascps", ":", "for", "_coordinator", "in", "self", ".", "_tracked_transfer_coordinators", ":", "_cou...
count the number of cooridnators currently being processed or count the number of ascps currently being used
[ "count", "the", "number", "of", "cooridnators", "currently", "being", "processed", "or", "count", "the", "number", "of", "ascps", "currently", "being", "used" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L481-L491
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferCoordinatorController._queue_task
def _queue_task(self, args): ''' add transfer to waiting queue if possible then notify the background thread to process it ''' if self._cancel_called: raise AsperaTransferQueueError("Cancel already called") elif self._wait_called: raise AsperaTransferQueueErro...
python
def _queue_task(self, args): ''' add transfer to waiting queue if possible then notify the background thread to process it ''' if self._cancel_called: raise AsperaTransferQueueError("Cancel already called") elif self._wait_called: raise AsperaTransferQueueErro...
[ "def", "_queue_task", "(", "self", ",", "args", ")", ":", "if", "self", ".", "_cancel_called", ":", "raise", "AsperaTransferQueueError", "(", "\"Cancel already called\"", ")", "elif", "self", ".", "_wait_called", ":", "raise", "AsperaTransferQueueError", "(", "\"C...
add transfer to waiting queue if possible then notify the background thread to process it
[ "add", "transfer", "to", "waiting", "queue", "if", "possible", "then", "notify", "the", "background", "thread", "to", "process", "it" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L503-L530
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferCoordinatorController.remove_aspera_coordinator
def remove_aspera_coordinator(self, transfer_coordinator): ''' remove entry from the waiting waiting or remove item from processig queue and add to processed quque notify background thread as it may be able to process watiign requests ''' # usually called on processing co...
python
def remove_aspera_coordinator(self, transfer_coordinator): ''' remove entry from the waiting waiting or remove item from processig queue and add to processed quque notify background thread as it may be able to process watiign requests ''' # usually called on processing co...
[ "def", "remove_aspera_coordinator", "(", "self", ",", "transfer_coordinator", ")", ":", "# usually called on processing completion - but can be called for a cancel", "if", "self", ".", "_in_waiting_queue", "(", "transfer_coordinator", ")", ":", "logger", ".", "info", "(", "...
remove entry from the waiting waiting or remove item from processig queue and add to processed quque notify background thread as it may be able to process watiign requests
[ "remove", "entry", "from", "the", "waiting", "waiting", "or", "remove", "item", "from", "processig", "queue", "and", "add", "to", "processed", "quque", "notify", "background", "thread", "as", "it", "may", "be", "able", "to", "process", "watiign", "requests" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L532-L550
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
AsperaTransferCoordinatorController.append_waiting_queue
def append_waiting_queue(self, transfer_coordinator): ''' append item to waiting queue ''' logger.debug("Add to waiting queue count=%d" % self.waiting_coordinator_count()) with self._lockw: self._waiting_transfer_coordinators.append(transfer_coordinator)
python
def append_waiting_queue(self, transfer_coordinator): ''' append item to waiting queue ''' logger.debug("Add to waiting queue count=%d" % self.waiting_coordinator_count()) with self._lockw: self._waiting_transfer_coordinators.append(transfer_coordinator)
[ "def", "append_waiting_queue", "(", "self", ",", "transfer_coordinator", ")", ":", "logger", ".", "debug", "(", "\"Add to waiting queue count=%d\"", "%", "self", ".", "waiting_coordinator_count", "(", ")", ")", "with", "self", ".", "_lockw", ":", "self", ".", "_...
append item to waiting queue
[ "append", "item", "to", "waiting", "queue" ]
train
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L552-L556