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
Hackerfleet/hfos
hfos/tool/installer.py
update
def update(ctx, no_restart, no_rebuild): """Update a HFOS node""" # 0. (NOT YET! MAKE A BACKUP OF EVERYTHING) # 1. update repository # 2. update frontend repository # 3. (Not yet: update venv) # 4. rebuild frontend # 5. restart service instance = ctx.obj['instance'] log('Pulling g...
python
def update(ctx, no_restart, no_rebuild): """Update a HFOS node""" # 0. (NOT YET! MAKE A BACKUP OF EVERYTHING) # 1. update repository # 2. update frontend repository # 3. (Not yet: update venv) # 4. rebuild frontend # 5. restart service instance = ctx.obj['instance'] log('Pulling g...
[ "def", "update", "(", "ctx", ",", "no_restart", ",", "no_rebuild", ")", ":", "# 0. (NOT YET! MAKE A BACKUP OF EVERYTHING)", "# 1. update repository", "# 2. update frontend repository", "# 3. (Not yet: update venv)", "# 4. rebuild frontend", "# 5. restart service", "instance", "=", ...
Update a HFOS node
[ "Update", "a", "HFOS", "node" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L688-L715
Hackerfleet/hfos
modules/nmea/hfos/nmea/nmea.py
NMEAParser.raw_data
def raw_data(self, event): """Handles incoming raw sensor data :param event: Raw sentences incoming data """ self.log('Received raw data from bus', lvl=events) if not parse: return nmea_time = event.data[0] try: parsed_data = parse(event....
python
def raw_data(self, event): """Handles incoming raw sensor data :param event: Raw sentences incoming data """ self.log('Received raw data from bus', lvl=events) if not parse: return nmea_time = event.data[0] try: parsed_data = parse(event....
[ "def", "raw_data", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Received raw data from bus'", ",", "lvl", "=", "events", ")", "if", "not", "parse", ":", "return", "nmea_time", "=", "event", ".", "data", "[", "0", "]", "try", ":", "...
Handles incoming raw sensor data :param event: Raw sentences incoming data
[ "Handles", "incoming", "raw", "sensor", "data", ":", "param", "event", ":", "Raw", "sentences", "incoming", "data" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/nmea/hfos/nmea/nmea.py#L106-L133
Hackerfleet/hfos
hfos/database.py
clear_all
def clear_all(): """DANGER! *This command is a maintenance tool and clears the complete database.* """ sure = input("Are you sure to drop the complete database content? (Type " "in upppercase YES)") if not (sure == 'YES'): db_log('Not deleting the database.') sys.ex...
python
def clear_all(): """DANGER! *This command is a maintenance tool and clears the complete database.* """ sure = input("Are you sure to drop the complete database content? (Type " "in upppercase YES)") if not (sure == 'YES'): db_log('Not deleting the database.') sys.ex...
[ "def", "clear_all", "(", ")", ":", "sure", "=", "input", "(", "\"Are you sure to drop the complete database content? (Type \"", "\"in upppercase YES)\"", ")", "if", "not", "(", "sure", "==", "'YES'", ")", ":", "db_log", "(", "'Not deleting the database.'", ")", "sys",...
DANGER! *This command is a maintenance tool and clears the complete database.*
[ "DANGER!", "*", "This", "command", "is", "a", "maintenance", "tool", "and", "clears", "the", "complete", "database", ".", "*" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L102-L118
Hackerfleet/hfos
hfos/database.py
_build_model_factories
def _build_model_factories(store): """Generate factories to construct objects from schemata""" result = {} for schemaname in store: schema = None try: schema = store[schemaname]['schema'] except KeyError: schemata_log("No schema found for ", schemaname, lv...
python
def _build_model_factories(store): """Generate factories to construct objects from schemata""" result = {} for schemaname in store: schema = None try: schema = store[schemaname]['schema'] except KeyError: schemata_log("No schema found for ", schemaname, lv...
[ "def", "_build_model_factories", "(", "store", ")", ":", "result", "=", "{", "}", "for", "schemaname", "in", "store", ":", "schema", "=", "None", "try", ":", "schema", "=", "store", "[", "schemaname", "]", "[", "'schema'", "]", "except", "KeyError", ":",...
Generate factories to construct objects from schemata
[ "Generate", "factories", "to", "construct", "objects", "from", "schemata" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L257-L276
Hackerfleet/hfos
hfos/database.py
_build_collections
def _build_collections(store): """Generate database collections with indices from the schemastore""" result = {} client = pymongo.MongoClient(host=dbhost, port=dbport) db = client[dbname] for schemaname in store: schema = None indices = None try: schema = sto...
python
def _build_collections(store): """Generate database collections with indices from the schemastore""" result = {} client = pymongo.MongoClient(host=dbhost, port=dbport) db = client[dbname] for schemaname in store: schema = None indices = None try: schema = sto...
[ "def", "_build_collections", "(", "store", ")", ":", "result", "=", "{", "}", "client", "=", "pymongo", ".", "MongoClient", "(", "host", "=", "dbhost", ",", "port", "=", "dbport", ")", "db", "=", "client", "[", "dbname", "]", "for", "schemaname", "in",...
Generate database collections with indices from the schemastore
[ "Generate", "database", "collections", "with", "indices", "from", "the", "schemastore" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L279-L349
Hackerfleet/hfos
hfos/database.py
initialize
def initialize(address='127.0.0.1:27017', database_name='hfos', instance_name="default", reload=False): """Initializes the database connectivity, schemata and finally object models""" global schemastore global l10n_schemastore global objectmodels global collections global dbhost global dbpo...
python
def initialize(address='127.0.0.1:27017', database_name='hfos', instance_name="default", reload=False): """Initializes the database connectivity, schemata and finally object models""" global schemastore global l10n_schemastore global objectmodels global collections global dbhost global dbpo...
[ "def", "initialize", "(", "address", "=", "'127.0.0.1:27017'", ",", "database_name", "=", "'hfos'", ",", "instance_name", "=", "\"default\"", ",", "reload", "=", "False", ")", ":", "global", "schemastore", "global", "l10n_schemastore", "global", "objectmodels", "g...
Initializes the database connectivity, schemata and finally object models
[ "Initializes", "the", "database", "connectivity", "schemata", "and", "finally", "object", "models" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L352-L392
Hackerfleet/hfos
hfos/database.py
profile
def profile(schemaname='sensordata', profiletype='pjs'): """Profiles object model handling with a very simple benchmarking test""" db_log("Profiling ", schemaname) schema = schemastore[schemaname]['schema'] db_log("Schema: ", schema, lvl=debug) testclass = None if profiletype == 'warmongo':...
python
def profile(schemaname='sensordata', profiletype='pjs'): """Profiles object model handling with a very simple benchmarking test""" db_log("Profiling ", schemaname) schema = schemastore[schemaname]['schema'] db_log("Schema: ", schema, lvl=debug) testclass = None if profiletype == 'warmongo':...
[ "def", "profile", "(", "schemaname", "=", "'sensordata'", ",", "profiletype", "=", "'pjs'", ")", ":", "db_log", "(", "\"Profiling \"", ",", "schemaname", ")", "schema", "=", "schemastore", "[", "schemaname", "]", "[", "'schema'", "]", "db_log", "(", "\"Schem...
Profiles object model handling with a very simple benchmarking test
[ "Profiles", "object", "model", "handling", "with", "a", "very", "simple", "benchmarking", "test" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L412-L449
Hackerfleet/hfos
hfos/database.py
backup
def backup(schema, uuid, export_filter, export_format, filename, pretty, export_all, omit): """Exports all collections to (JSON-) files.""" export_format = export_format.upper() if pretty: indent = 4 else: indent = 0 f = None if filename: try: f = open(fil...
python
def backup(schema, uuid, export_filter, export_format, filename, pretty, export_all, omit): """Exports all collections to (JSON-) files.""" export_format = export_format.upper() if pretty: indent = 4 else: indent = 0 f = None if filename: try: f = open(fil...
[ "def", "backup", "(", "schema", ",", "uuid", ",", "export_filter", ",", "export_format", ",", "filename", ",", "pretty", ",", "export_all", ",", "omit", ")", ":", "export_format", "=", "export_format", ".", "upper", "(", ")", "if", "pretty", ":", "indent",...
Exports all collections to (JSON-) files.
[ "Exports", "all", "collections", "to", "(", "JSON", "-", ")", "files", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L657-L733
Hackerfleet/hfos
hfos/database.py
Maintenance._check_collections
def _check_collections(self): """Checks node local collection storage sizes""" self.collection_sizes = {} self.collection_total = 0 for col in self.db.collection_names(include_system_collections=False): self.collection_sizes[col] = self.db.command('collstats', col).get( ...
python
def _check_collections(self): """Checks node local collection storage sizes""" self.collection_sizes = {} self.collection_total = 0 for col in self.db.collection_names(include_system_collections=False): self.collection_sizes[col] = self.db.command('collstats', col).get( ...
[ "def", "_check_collections", "(", "self", ")", ":", "self", ".", "collection_sizes", "=", "{", "}", "self", ".", "collection_total", "=", "0", "for", "col", "in", "self", ".", "db", ".", "collection_names", "(", "include_system_collections", "=", "False", ")...
Checks node local collection storage sizes
[ "Checks", "node", "local", "collection", "storage", "sizes" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L558-L577
Hackerfleet/hfos
hfos/database.py
Maintenance._check_free_space
def _check_free_space(self): """Checks used filesystem storage sizes""" def get_folder_size(path): """Aggregates used size of a specified path, recursively""" total_size = 0 for item in walk(path): for file in item[2]: try: ...
python
def _check_free_space(self): """Checks used filesystem storage sizes""" def get_folder_size(path): """Aggregates used size of a specified path, recursively""" total_size = 0 for item in walk(path): for file in item[2]: try: ...
[ "def", "_check_free_space", "(", "self", ")", ":", "def", "get_folder_size", "(", "path", ")", ":", "\"\"\"Aggregates used size of a specified path, recursively\"\"\"", "total_size", "=", "0", "for", "item", "in", "walk", "(", "path", ")", ":", "for", "file", "in"...
Checks used filesystem storage sizes
[ "Checks", "used", "filesystem", "storage", "sizes" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L579-L611
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
send_mail_worker
def send_mail_worker(config, mail, event): """Worker task to send out an email, which blocks the process unless it is threaded""" log = "" try: if config.mail_ssl: server = SMTP_SSL(config.mail_server, port=config.mail_server_port, timeout=30) else: server = SMTP(con...
python
def send_mail_worker(config, mail, event): """Worker task to send out an email, which blocks the process unless it is threaded""" log = "" try: if config.mail_ssl: server = SMTP_SSL(config.mail_server, port=config.mail_server_port, timeout=30) else: server = SMTP(con...
[ "def", "send_mail_worker", "(", "config", ",", "mail", ",", "event", ")", ":", "log", "=", "\"\"", "try", ":", "if", "config", ".", "mail_ssl", ":", "server", "=", "SMTP_SSL", "(", "config", ".", "mail_server", ",", "port", "=", "config", ".", "mail_se...
Worker task to send out an email, which blocks the process unless it is threaded
[ "Worker", "task", "to", "send", "out", "an", "email", "which", "blocks", "the", "process", "unless", "it", "is", "threaded" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L792-L821
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.reload_configuration
def reload_configuration(self, event): """Reload the current configuration and set up everything depending on it""" super(EnrolManager, self).reload_configuration(event) self.log('Reloaded configuration.') self._setup()
python
def reload_configuration(self, event): """Reload the current configuration and set up everything depending on it""" super(EnrolManager, self).reload_configuration(event) self.log('Reloaded configuration.') self._setup()
[ "def", "reload_configuration", "(", "self", ",", "event", ")", ":", "super", "(", "EnrolManager", ",", "self", ")", ".", "reload_configuration", "(", "event", ")", "self", ".", "log", "(", "'Reloaded configuration.'", ")", "self", ".", "_setup", "(", ")" ]
Reload the current configuration and set up everything depending on it
[ "Reload", "the", "current", "configuration", "and", "set", "up", "everything", "depending", "on", "it" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L261-L266
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.change
def change(self, event): """An admin user requests a change to an enrolment""" uuid = event.data['uuid'] status = event.data['status'] if status not in ['Open', 'Pending', 'Accepted', 'Denied', 'Resend']: self.log('Erroneous status for enrollment requested!', lvl=warn) ...
python
def change(self, event): """An admin user requests a change to an enrolment""" uuid = event.data['uuid'] status = event.data['status'] if status not in ['Open', 'Pending', 'Accepted', 'Denied', 'Resend']: self.log('Erroneous status for enrollment requested!', lvl=warn) ...
[ "def", "change", "(", "self", ",", "event", ")", ":", "uuid", "=", "event", ".", "data", "[", "'uuid'", "]", "status", "=", "event", ".", "data", "[", "'status'", "]", "if", "status", "not", "in", "[", "'Open'", ",", "'Pending'", ",", "'Accepted'", ...
An admin user requests a change to an enrolment
[ "An", "admin", "user", "requests", "a", "change", "to", "an", "enrolment" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L315-L354
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.changepassword
def changepassword(self, event): """An enrolled user wants to change their password""" old = event.data['old'] new = event.data['new'] uuid = event.user.uuid # TODO: Write email to notify user of password change user = objectmodels['user'].find_one({'uuid': uuid}) ...
python
def changepassword(self, event): """An enrolled user wants to change their password""" old = event.data['old'] new = event.data['new'] uuid = event.user.uuid # TODO: Write email to notify user of password change user = objectmodels['user'].find_one({'uuid': uuid}) ...
[ "def", "changepassword", "(", "self", ",", "event", ")", ":", "old", "=", "event", ".", "data", "[", "'old'", "]", "new", "=", "event", ".", "data", "[", "'new'", "]", "uuid", "=", "event", ".", "user", ".", "uuid", "# TODO: Write email to notify user of...
An enrolled user wants to change their password
[ "An", "enrolled", "user", "wants", "to", "change", "their", "password" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L357-L385
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.invite
def invite(self, event): """A new user has been invited to enrol by an admin user""" self.log('Inviting new user to enrol') name = event.data['name'] email = event.data['email'] method = event.data['method'] self._invite(name, method, email, event.client.uuid, event)
python
def invite(self, event): """A new user has been invited to enrol by an admin user""" self.log('Inviting new user to enrol') name = event.data['name'] email = event.data['email'] method = event.data['method'] self._invite(name, method, email, event.client.uuid, event)
[ "def", "invite", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Inviting new user to enrol'", ")", "name", "=", "event", ".", "data", "[", "'name'", "]", "email", "=", "event", ".", "data", "[", "'email'", "]", "method", "=", "event", ...
A new user has been invited to enrol by an admin user
[ "A", "new", "user", "has", "been", "invited", "to", "enrol", "by", "an", "admin", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L388-L396
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.enrol
def enrol(self, event): """A user tries to self-enrol with the enrolment form""" if self.config.allow_registration is False: self.log('Someone tried to register although enrolment is closed.') return self.log('Client trying to register a new account:', event, pretty=Tru...
python
def enrol(self, event): """A user tries to self-enrol with the enrolment form""" if self.config.allow_registration is False: self.log('Someone tried to register although enrolment is closed.') return self.log('Client trying to register a new account:', event, pretty=Tru...
[ "def", "enrol", "(", "self", ",", "event", ")", ":", "if", "self", ".", "config", ".", "allow_registration", "is", "False", ":", "self", ".", "log", "(", "'Someone tried to register although enrolment is closed.'", ")", "return", "self", ".", "log", "(", "'Cli...
A user tries to self-enrol with the enrolment form
[ "A", "user", "tries", "to", "self", "-", "enrol", "with", "the", "enrolment", "form" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L399-L450
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.accept
def accept(self, event): """A challenge/response for an enrolment has been accepted""" self.log('Invitation accepted:', event.__dict__, lvl=debug) try: uuid = event.data enrollment = objectmodels['enrollment'].find_one({ 'uuid': uuid }) ...
python
def accept(self, event): """A challenge/response for an enrolment has been accepted""" self.log('Invitation accepted:', event.__dict__, lvl=debug) try: uuid = event.data enrollment = objectmodels['enrollment'].find_one({ 'uuid': uuid }) ...
[ "def", "accept", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Invitation accepted:'", ",", "event", ".", "__dict__", ",", "lvl", "=", "debug", ")", "try", ":", "uuid", "=", "event", ".", "data", "enrollment", "=", "objectmodels", "["...
A challenge/response for an enrolment has been accepted
[ "A", "challenge", "/", "response", "for", "an", "enrolment", "has", "been", "accepted" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L453-L514
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.status
def status(self, event): """An anonymous client wants to know if we're open for enrollment""" self.log('Registration status requested') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'status', 'data': self.config.allow_registration } ...
python
def status(self, event): """An anonymous client wants to know if we're open for enrollment""" self.log('Registration status requested') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'status', 'data': self.config.allow_registration } ...
[ "def", "status", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Registration status requested'", ")", "response", "=", "{", "'component'", ":", "'hfos.enrol.enrolmanager'", ",", "'action'", ":", "'status'", ",", "'data'", ":", "self", ".", "...
An anonymous client wants to know if we're open for enrollment
[ "An", "anonymous", "client", "wants", "to", "know", "if", "we", "re", "open", "for", "enrollment" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L517-L528
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.request_reset
def request_reset(self, event): """An anonymous client requests a password reset""" self.log('Password reset request received:', event.__dict__, lvl=hilight) user_object = objectmodels['user'] email = event.data.get('email', None) email_user = None if email is not Non...
python
def request_reset(self, event): """An anonymous client requests a password reset""" self.log('Password reset request received:', event.__dict__, lvl=hilight) user_object = objectmodels['user'] email = event.data.get('email', None) email_user = None if email is not Non...
[ "def", "request_reset", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Password reset request received:'", ",", "event", ".", "__dict__", ",", "lvl", "=", "hilight", ")", "user_object", "=", "objectmodels", "[", "'user'", "]", "email", "=", ...
An anonymous client requests a password reset
[ "An", "anonymous", "client", "requests", "a", "password", "reset" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L537-L552
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager.captcha_transmit
def captcha_transmit(self, captcha, uuid): """Delayed transmission of a requested captcha""" self.log('Transmitting captcha') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'captcha', 'data': b64encode(captcha['image'].getvalue()).decode('utf...
python
def captcha_transmit(self, captcha, uuid): """Delayed transmission of a requested captcha""" self.log('Transmitting captcha') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'captcha', 'data': b64encode(captcha['image'].getvalue()).decode('utf...
[ "def", "captcha_transmit", "(", "self", ",", "captcha", ",", "uuid", ")", ":", "self", ".", "log", "(", "'Transmitting captcha'", ")", "response", "=", "{", "'component'", ":", "'hfos.enrol.enrolmanager'", ",", "'action'", ":", "'captcha'", ",", "'data'", ":",...
Delayed transmission of a requested captcha
[ "Delayed", "transmission", "of", "a", "requested", "captcha" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L639-L649
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager._invite
def _invite(self, name, method, email, uuid, event, password=""): """Actually invite a given user""" props = { 'uuid': std_uuid(), 'status': 'Open', 'name': name, 'method': method, 'email': email, 'password': password, ...
python
def _invite(self, name, method, email, uuid, event, password=""): """Actually invite a given user""" props = { 'uuid': std_uuid(), 'status': 'Open', 'name': name, 'method': method, 'email': email, 'password': password, ...
[ "def", "_invite", "(", "self", ",", "name", ",", "method", ",", "email", ",", "uuid", ",", "event", ",", "password", "=", "\"\"", ")", ":", "props", "=", "{", "'uuid'", ":", "std_uuid", "(", ")", ",", "'status'", ":", "'Open'", ",", "'name'", ":", ...
Actually invite a given user
[ "Actually", "invite", "a", "given", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L651-L675
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager._create_user
def _create_user(self, username, password, mail, method, uuid): """Create a new user and all initial data""" try: if method == 'Invited': config_role = self.config.group_accept_invited else: config_role = self.config.group_accept_enrolled ...
python
def _create_user(self, username, password, mail, method, uuid): """Create a new user and all initial data""" try: if method == 'Invited': config_role = self.config.group_accept_invited else: config_role = self.config.group_accept_enrolled ...
[ "def", "_create_user", "(", "self", ",", "username", ",", "password", ",", "mail", ",", "method", ",", "uuid", ")", ":", "try", ":", "if", "method", "==", "'Invited'", ":", "config_role", "=", "self", ".", "config", ".", "group_accept_invited", "else", "...
Create a new user and all initial data
[ "Create", "a", "new", "user", "and", "all", "initial", "data" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L677-L731
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager._send_invitation
def _send_invitation(self, enrollment, event): """Send an invitation mail to an open enrolment""" self.log('Sending enrollment status mail to user') self._send_mail(self.config.invitation_subject, self.config.invitation_mail, enrollment, event)
python
def _send_invitation(self, enrollment, event): """Send an invitation mail to an open enrolment""" self.log('Sending enrollment status mail to user') self._send_mail(self.config.invitation_subject, self.config.invitation_mail, enrollment, event)
[ "def", "_send_invitation", "(", "self", ",", "enrollment", ",", "event", ")", ":", "self", ".", "log", "(", "'Sending enrollment status mail to user'", ")", "self", ".", "_send_mail", "(", "self", ".", "config", ".", "invitation_subject", ",", "self", ".", "co...
Send an invitation mail to an open enrolment
[ "Send", "an", "invitation", "mail", "to", "an", "open", "enrolment" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L733-L738
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager._send_acceptance
def _send_acceptance(self, enrollment, password, event): """Send an acceptance mail to an open enrolment""" self.log('Sending acceptance status mail to user') if password is not "": password_hint = '\n\nPS: Your new password is ' + password + ' - please change it after your first l...
python
def _send_acceptance(self, enrollment, password, event): """Send an acceptance mail to an open enrolment""" self.log('Sending acceptance status mail to user') if password is not "": password_hint = '\n\nPS: Your new password is ' + password + ' - please change it after your first l...
[ "def", "_send_acceptance", "(", "self", ",", "enrollment", ",", "password", ",", "event", ")", ":", "self", ".", "log", "(", "'Sending acceptance status mail to user'", ")", "if", "password", "is", "not", "\"\"", ":", "password_hint", "=", "'\\n\\nPS: Your new pas...
Send an acceptance mail to an open enrolment
[ "Send", "an", "acceptance", "mail", "to", "an", "open", "enrolment" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L740-L752
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
EnrolManager._send_mail
def _send_mail(self, subject, template, enrollment, event): """Connect to mail server and send actual email""" context = { 'name': enrollment.name, 'invitation_url': self.invitation_url, 'node_name': self.node_name, 'node_url': self.node_url, ...
python
def _send_mail(self, subject, template, enrollment, event): """Connect to mail server and send actual email""" context = { 'name': enrollment.name, 'invitation_url': self.invitation_url, 'node_name': self.node_name, 'node_url': self.node_url, ...
[ "def", "_send_mail", "(", "self", ",", "subject", ",", "template", ",", "enrollment", ",", "event", ")", ":", "context", "=", "{", "'name'", ":", "enrollment", ".", "name", ",", "'invitation_url'", ":", "self", ".", "invitation_url", ",", "'node_name'", ":...
Connect to mail server and send actual email
[ "Connect", "to", "mail", "server", "and", "send", "actual", "email" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L754-L778
Hackerfleet/hfos
modules/chat/hfos/chat/bot.py
Bot.say
def say(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: userid = event.user.uuid recipient = self._get_recipient(event) content = self._get_content(event) if self.config....
python
def say(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: userid = event.user.uuid recipient = self._get_recipient(event) content = self._get_content(event) if self.config....
[ "def", "say", "(", "self", ",", "event", ")", ":", "try", ":", "userid", "=", "event", ".", "user", ".", "uuid", "recipient", "=", "self", ".", "_get_recipient", "(", "event", ")", "content", "=", "self", ".", "_get_content", "(", "event", ")", "if",...
Chat event handler for incoming events :param event: say-event with incoming chat message
[ "Chat", "event", "handler", "for", "incoming", "events", ":", "param", "event", ":", "say", "-", "event", "with", "incoming", "chat", "message" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/bot.py#L67-L81
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator.add_auth_hook
def add_auth_hook(self, event): """Register event hook on reception of add_auth_hook-event""" self.log('Adding authentication hook for', event.authenticator_name) self.auth_hooks[event.authenticator_name] = event.event
python
def add_auth_hook(self, event): """Register event hook on reception of add_auth_hook-event""" self.log('Adding authentication hook for', event.authenticator_name) self.auth_hooks[event.authenticator_name] = event.event
[ "def", "add_auth_hook", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Adding authentication hook for'", ",", "event", ".", "authenticator_name", ")", "self", ".", "auth_hooks", "[", "event", ".", "authenticator_name", "]", "=", "event", ".", ...
Register event hook on reception of add_auth_hook-event
[ "Register", "event", "hook", "on", "reception", "of", "add_auth_hook", "-", "event" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L90-L94
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator._fail
def _fail(self, event, message='Invalid credentials'): """Sends a failure message to the requesting client""" notification = { 'component': 'auth', 'action': 'fail', 'data': message } ip = event.sock.getpeername()[0] self.failing_clients[ip]...
python
def _fail(self, event, message='Invalid credentials'): """Sends a failure message to the requesting client""" notification = { 'component': 'auth', 'action': 'fail', 'data': message } ip = event.sock.getpeername()[0] self.failing_clients[ip]...
[ "def", "_fail", "(", "self", ",", "event", ",", "message", "=", "'Invalid credentials'", ")", ":", "notification", "=", "{", "'component'", ":", "'auth'", ",", "'action'", ":", "'fail'", ",", "'data'", ":", "message", "}", "ip", "=", "event", ".", "sock"...
Sends a failure message to the requesting client
[ "Sends", "a", "failure", "message", "to", "the", "requesting", "client" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L96-L108
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator._login
def _login(self, event, user_account, user_profile, client_config): """Send login notification to client""" user_account.lastlogin = std_now() user_account.save() user_account.passhash = "" self.fireEvent( authentication(user_account.name, ( user_acc...
python
def _login(self, event, user_account, user_profile, client_config): """Send login notification to client""" user_account.lastlogin = std_now() user_account.save() user_account.passhash = "" self.fireEvent( authentication(user_account.name, ( user_acc...
[ "def", "_login", "(", "self", ",", "event", ",", "user_account", ",", "user_profile", ",", "client_config", ")", ":", "user_account", ".", "lastlogin", "=", "std_now", "(", ")", "user_account", ".", "save", "(", ")", "user_account", ".", "passhash", "=", "...
Send login notification to client
[ "Send", "login", "notification", "to", "client" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L115-L128
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator.authenticationrequest
def authenticationrequest(self, event): """Handles authentication requests from clients :param event: AuthenticationRequest with user's credentials """ if event.sock.getpeername()[0] in self.failing_clients: self.log('Client failed a login and has to wait', lvl=debug) ...
python
def authenticationrequest(self, event): """Handles authentication requests from clients :param event: AuthenticationRequest with user's credentials """ if event.sock.getpeername()[0] in self.failing_clients: self.log('Client failed a login and has to wait', lvl=debug) ...
[ "def", "authenticationrequest", "(", "self", ",", "event", ")", ":", "if", "event", ".", "sock", ".", "getpeername", "(", ")", "[", "0", "]", "in", "self", ".", "failing_clients", ":", "self", ".", "log", "(", "'Client failed a login and has to wait'", ",", ...
Handles authentication requests from clients :param event: AuthenticationRequest with user's credentials
[ "Handles", "authentication", "requests", "from", "clients", ":", "param", "event", ":", "AuthenticationRequest", "with", "user", "s", "credentials" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L131-L143
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator._handle_autologin
def _handle_autologin(self, event): """Automatic logins for client configurations that allow it""" self.log("Verifying automatic login request") # TODO: Check for a common secret # noinspection PyBroadException try: client_config = objectmodels['client'].find_one({...
python
def _handle_autologin(self, event): """Automatic logins for client configurations that allow it""" self.log("Verifying automatic login request") # TODO: Check for a common secret # noinspection PyBroadException try: client_config = objectmodels['client'].find_one({...
[ "def", "_handle_autologin", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Verifying automatic login request\"", ")", "# TODO: Check for a common secret", "# noinspection PyBroadException", "try", ":", "client_config", "=", "objectmodels", "[", "'client'...
Automatic logins for client configurations that allow it
[ "Automatic", "logins", "for", "client", "configurations", "that", "allow", "it" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L145-L188
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator._handle_login
def _handle_login(self, event): """Manual password based login""" # TODO: Refactor to simplify self.log("Auth request for ", event.username, 'client:', event.clientuuid) # TODO: Define the requirements for secure passwords etc. # They're also required in the E...
python
def _handle_login(self, event): """Manual password based login""" # TODO: Refactor to simplify self.log("Auth request for ", event.username, 'client:', event.clientuuid) # TODO: Define the requirements for secure passwords etc. # They're also required in the E...
[ "def", "_handle_login", "(", "self", ",", "event", ")", ":", "# TODO: Refactor to simplify", "self", ".", "log", "(", "\"Auth request for \"", ",", "event", ".", "username", ",", "'client:'", ",", "event", ".", "clientuuid", ")", "# TODO: Define the requirements for...
Manual password based login
[ "Manual", "password", "based", "login" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L190-L275
Hackerfleet/hfos
hfos/ui/auth.py
Authenticator._get_profile
def _get_profile(self, user_account): """Retrieves a user's profile""" try: # TODO: Load active profile, not just any user_profile = objectmodels['profile'].find_one( {'owner': str(user_account.uuid)}) self.log("Profile: ", user_profile, ...
python
def _get_profile(self, user_account): """Retrieves a user's profile""" try: # TODO: Load active profile, not just any user_profile = objectmodels['profile'].find_one( {'owner': str(user_account.uuid)}) self.log("Profile: ", user_profile, ...
[ "def", "_get_profile", "(", "self", ",", "user_account", ")", ":", "try", ":", "# TODO: Load active profile, not just any", "user_profile", "=", "objectmodels", "[", "'profile'", "]", ".", "find_one", "(", "{", "'owner'", ":", "str", "(", "user_account", ".", "u...
Retrieves a user's profile
[ "Retrieves", "a", "user", "s", "profile" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L277-L302
Hackerfleet/hfos
modules/navdata/hfos/navdata/bus.py
SerialBusManager._parse
def _parse(self, bus, data): """ Called when a sensor sends a new raw data to this serial connector. The data is sanitized and sent to the registered protocol listeners as time/raw/bus sentence tuple. """ sen_time = time.time() try: # Split up multi...
python
def _parse(self, bus, data): """ Called when a sensor sends a new raw data to this serial connector. The data is sanitized and sent to the registered protocol listeners as time/raw/bus sentence tuple. """ sen_time = time.time() try: # Split up multi...
[ "def", "_parse", "(", "self", ",", "bus", ",", "data", ")", ":", "sen_time", "=", "time", ".", "time", "(", ")", "try", ":", "# Split up multiple sentences", "if", "isinstance", "(", "data", ",", "bytes", ")", ":", "data", "=", "data", ".", "decode", ...
Called when a sensor sends a new raw data to this serial connector. The data is sanitized and sent to the registered protocol listeners as time/raw/bus sentence tuple.
[ "Called", "when", "a", "sensor", "sends", "a", "new", "raw", "data", "to", "this", "serial", "connector", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/bus.py#L534-L567
Hackerfleet/hfos
modules/navdata/hfos/navdata/bus.py
SerialBusManager.serial_packet
def serial_packet(self, event): """Handles incoming raw sensor data :param data: raw incoming data """ self.log('Incoming serial packet:', event.__dict__, lvl=verbose) if self.scanning: pass else: # self.log("Incoming data: ", '%.50s ...' % event...
python
def serial_packet(self, event): """Handles incoming raw sensor data :param data: raw incoming data """ self.log('Incoming serial packet:', event.__dict__, lvl=verbose) if self.scanning: pass else: # self.log("Incoming data: ", '%.50s ...' % event...
[ "def", "serial_packet", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Incoming serial packet:'", ",", "event", ".", "__dict__", ",", "lvl", "=", "verbose", ")", "if", "self", ".", "scanning", ":", "pass", "else", ":", "# self.log(\"Incomi...
Handles incoming raw sensor data :param data: raw incoming data
[ "Handles", "incoming", "raw", "sensor", "data", ":", "param", "data", ":", "raw", "incoming", "data" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/bus.py#L583-L597
aburrell/apexpy
src/apexpy/__main__.py
main
def main(): """Entry point for the script""" desc = 'Converts between geodetic, modified apex, quasi-dipole and MLT' parser = argparse.ArgumentParser(description=desc, prog='apexpy') parser.add_argument('source', metavar='SOURCE', choices=['geo', 'apex', 'qd', 'mlt'], ...
python
def main(): """Entry point for the script""" desc = 'Converts between geodetic, modified apex, quasi-dipole and MLT' parser = argparse.ArgumentParser(description=desc, prog='apexpy') parser.add_argument('source', metavar='SOURCE', choices=['geo', 'apex', 'qd', 'mlt'], ...
[ "def", "main", "(", ")", ":", "desc", "=", "'Converts between geodetic, modified apex, quasi-dipole and MLT'", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "desc", ",", "prog", "=", "'apexpy'", ")", "parser", ".", "add_argument", "(", ...
Entry point for the script
[ "Entry", "point", "for", "the", "script" ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/__main__.py#L24-L68
Hackerfleet/hfos
hfos/tool/__init__.py
run_process
def run_process(cwd, args): """Executes an external process via subprocess.Popen""" try: process = check_output(args, cwd=cwd, stderr=STDOUT) return process except CalledProcessError as e: log('Uh oh, the teapot broke again! Error:', e, type(e), lvl=verbose, pretty=True) log...
python
def run_process(cwd, args): """Executes an external process via subprocess.Popen""" try: process = check_output(args, cwd=cwd, stderr=STDOUT) return process except CalledProcessError as e: log('Uh oh, the teapot broke again! Error:', e, type(e), lvl=verbose, pretty=True) log...
[ "def", "run_process", "(", "cwd", ",", "args", ")", ":", "try", ":", "process", "=", "check_output", "(", "args", ",", "cwd", "=", "cwd", ",", "stderr", "=", "STDOUT", ")", "return", "process", "except", "CalledProcessError", "as", "e", ":", "log", "("...
Executes an external process via subprocess.Popen
[ "Executes", "an", "external", "process", "via", "subprocess", ".", "Popen" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L66-L75
Hackerfleet/hfos
hfos/tool/__init__.py
_ask_password
def _ask_password(): """Securely and interactively ask for a password""" password = "Foo" password_trial = "" while password != password_trial: password = getpass.getpass() password_trial = getpass.getpass(prompt="Repeat:") if password != password_trial: print("\nPa...
python
def _ask_password(): """Securely and interactively ask for a password""" password = "Foo" password_trial = "" while password != password_trial: password = getpass.getpass() password_trial = getpass.getpass(prompt="Repeat:") if password != password_trial: print("\nPa...
[ "def", "_ask_password", "(", ")", ":", "password", "=", "\"Foo\"", "password_trial", "=", "\"\"", "while", "password", "!=", "password_trial", ":", "password", "=", "getpass", ".", "getpass", "(", ")", "password_trial", "=", "getpass", ".", "getpass", "(", "...
Securely and interactively ask for a password
[ "Securely", "and", "interactively", "ask", "for", "a", "password" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L78-L90
Hackerfleet/hfos
hfos/tool/__init__.py
_get_credentials
def _get_credentials(username=None, password=None, dbhost=None): """Obtain user credentials by arguments or asking the user""" # Database salt system_config = dbhost.objectmodels['systemconfig'].find_one({ 'active': True }) try: salt = system_config.salt.encode('ascii') except ...
python
def _get_credentials(username=None, password=None, dbhost=None): """Obtain user credentials by arguments or asking the user""" # Database salt system_config = dbhost.objectmodels['systemconfig'].find_one({ 'active': True }) try: salt = system_config.salt.encode('ascii') except ...
[ "def", "_get_credentials", "(", "username", "=", "None", ",", "password", "=", "None", ",", "dbhost", "=", "None", ")", ":", "# Database salt", "system_config", "=", "dbhost", ".", "objectmodels", "[", "'systemconfig'", "]", ".", "find_one", "(", "{", "'acti...
Obtain user credentials by arguments or asking the user
[ "Obtain", "user", "credentials", "by", "arguments", "or", "asking", "the", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L93-L127
Hackerfleet/hfos
hfos/tool/__init__.py
_ask
def _ask(question, default=None, data_type='str', show_hint=False): """Interactively ask the user for data""" data = default if data_type == 'bool': data = None default_string = "Y" if default else "N" while data not in ('Y', 'J', 'N', '1', '0'): data = input("%s? [%s]...
python
def _ask(question, default=None, data_type='str', show_hint=False): """Interactively ask the user for data""" data = default if data_type == 'bool': data = None default_string = "Y" if default else "N" while data not in ('Y', 'J', 'N', '1', '0'): data = input("%s? [%s]...
[ "def", "_ask", "(", "question", ",", "default", "=", "None", ",", "data_type", "=", "'str'", ",", "show_hint", "=", "False", ")", ":", "data", "=", "default", "if", "data_type", "==", "'bool'", ":", "data", "=", "None", "default_string", "=", "\"Y\"", ...
Interactively ask the user for data
[ "Interactively", "ask", "the", "user", "for", "data" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L140-L180
aburrell/apexpy
src/apexpy/helpers.py
checklat
def checklat(lat, name='lat'): """Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4). Parameters ========== lat : array_like latitude name : str, optional parameter name to use in the exception message Returns ======= lat : ndarray o...
python
def checklat(lat, name='lat'): """Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4). Parameters ========== lat : array_like latitude name : str, optional parameter name to use in the exception message Returns ======= lat : ndarray o...
[ "def", "checklat", "(", "lat", ",", "name", "=", "'lat'", ")", ":", "if", "np", ".", "all", "(", "np", ".", "float64", "(", "lat", ")", ">=", "-", "90", ")", "and", "np", ".", "all", "(", "np", ".", "float64", "(", "lat", ")", "<=", "90", "...
Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4). Parameters ========== lat : array_like latitude name : str, optional parameter name to use in the exception message Returns ======= lat : ndarray or float Same as input where va...
[ "Makes", "sure", "the", "latitude", "is", "inside", "[", "-", "90", "90", "]", "clipping", "close", "values", "(", "tolerance", "1e", "-", "4", ")", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L11-L52
aburrell/apexpy
src/apexpy/helpers.py
getsinIm
def getsinIm(alat): """Computes sinIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= sinIm : ndarray or float """ alat = np.float64(alat) return 2*np.sin(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(al...
python
def getsinIm(alat): """Computes sinIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= sinIm : ndarray or float """ alat = np.float64(alat) return 2*np.sin(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(al...
[ "def", "getsinIm", "(", "alat", ")", ":", "alat", "=", "np", ".", "float64", "(", "alat", ")", "return", "2", "*", "np", ".", "sin", "(", "np", ".", "radians", "(", "alat", ")", ")", "/", "np", ".", "sqrt", "(", "4", "-", "3", "*", "np", "....
Computes sinIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= sinIm : ndarray or float
[ "Computes", "sinIm", "from", "modified", "apex", "latitude", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L55-L71
aburrell/apexpy
src/apexpy/helpers.py
getcosIm
def getcosIm(alat): """Computes cosIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= cosIm : ndarray or float """ alat = np.float64(alat) return np.cos(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(alat...
python
def getcosIm(alat): """Computes cosIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= cosIm : ndarray or float """ alat = np.float64(alat) return np.cos(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(alat...
[ "def", "getcosIm", "(", "alat", ")", ":", "alat", "=", "np", ".", "float64", "(", "alat", ")", "return", "np", ".", "cos", "(", "np", ".", "radians", "(", "alat", ")", ")", "/", "np", ".", "sqrt", "(", "4", "-", "3", "*", "np", ".", "cos", ...
Computes cosIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= cosIm : ndarray or float
[ "Computes", "cosIm", "from", "modified", "apex", "latitude", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L74-L90
aburrell/apexpy
src/apexpy/helpers.py
toYearFraction
def toYearFraction(date): """Converts :class:`datetime.date` or :class:`datetime.datetime` to decimal year. Parameters ========== date : :class:`datetime.date` or :class:`datetime.datetime` Returns ======= year : float Decimal year Notes ===== The algorithm is take...
python
def toYearFraction(date): """Converts :class:`datetime.date` or :class:`datetime.datetime` to decimal year. Parameters ========== date : :class:`datetime.date` or :class:`datetime.datetime` Returns ======= year : float Decimal year Notes ===== The algorithm is take...
[ "def", "toYearFraction", "(", "date", ")", ":", "def", "sinceEpoch", "(", "date", ")", ":", "\"\"\"returns seconds since epoch\"\"\"", "return", "time", ".", "mktime", "(", "date", ".", "timetuple", "(", ")", ")", "year", "=", "date", ".", "year", "startOfTh...
Converts :class:`datetime.date` or :class:`datetime.datetime` to decimal year. Parameters ========== date : :class:`datetime.date` or :class:`datetime.datetime` Returns ======= year : float Decimal year Notes ===== The algorithm is taken from http://stackoverflow.com/a...
[ "Converts", ":", "class", ":", "datetime", ".", "date", "or", ":", "class", ":", "datetime", ".", "datetime", "to", "decimal", "year", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L93-L123
aburrell/apexpy
src/apexpy/helpers.py
gc2gdlat
def gc2gdlat(gclat): """Converts geocentric latitude to geodetic latitude using WGS84. Parameters ========== gclat : array_like Geocentric latitude Returns ======= gdlat : ndarray or float Geodetic latitude """ WGS84_e2 = 0.006694379990141317 # WGS84 first eccentr...
python
def gc2gdlat(gclat): """Converts geocentric latitude to geodetic latitude using WGS84. Parameters ========== gclat : array_like Geocentric latitude Returns ======= gdlat : ndarray or float Geodetic latitude """ WGS84_e2 = 0.006694379990141317 # WGS84 first eccentr...
[ "def", "gc2gdlat", "(", "gclat", ")", ":", "WGS84_e2", "=", "0.006694379990141317", "# WGS84 first eccentricity squared", "return", "np", ".", "rad2deg", "(", "-", "np", ".", "arctan", "(", "np", ".", "tan", "(", "np", ".", "deg2rad", "(", "gclat", ")", ")...
Converts geocentric latitude to geodetic latitude using WGS84. Parameters ========== gclat : array_like Geocentric latitude Returns ======= gdlat : ndarray or float Geodetic latitude
[ "Converts", "geocentric", "latitude", "to", "geodetic", "latitude", "using", "WGS84", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L126-L141
aburrell/apexpy
src/apexpy/helpers.py
subsol
def subsol(datetime): """Finds subsolar geocentric latitude and longitude. Parameters ========== datetime : :class:`datetime.datetime` Returns ======= sbsllat : float Latitude of subsolar point sbsllon : float Longitude of subsolar point Notes ===== Based o...
python
def subsol(datetime): """Finds subsolar geocentric latitude and longitude. Parameters ========== datetime : :class:`datetime.datetime` Returns ======= sbsllat : float Latitude of subsolar point sbsllon : float Longitude of subsolar point Notes ===== Based o...
[ "def", "subsol", "(", "datetime", ")", ":", "# convert to year, day of year and seconds since midnight", "year", "=", "datetime", ".", "year", "doy", "=", "datetime", ".", "timetuple", "(", ")", ".", "tm_yday", "ut", "=", "datetime", ".", "hour", "*", "3600", ...
Finds subsolar geocentric latitude and longitude. Parameters ========== datetime : :class:`datetime.datetime` Returns ======= sbsllat : float Latitude of subsolar point sbsllon : float Longitude of subsolar point Notes ===== Based on formulas in Astronomical Al...
[ "Finds", "subsolar", "geocentric", "latitude", "and", "longitude", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L144-L226
aburrell/apexpy
ci/appveyor-download.py
make_auth_headers
def make_auth_headers(): """Make the authentication headers needed to use the Appveyor API.""" if not os.path.exists(".appveyor.token"): raise RuntimeError( "Please create a file named `.appveyor.token` in the current directory. " "You can get the token from https://ci.appveyor.c...
python
def make_auth_headers(): """Make the authentication headers needed to use the Appveyor API.""" if not os.path.exists(".appveyor.token"): raise RuntimeError( "Please create a file named `.appveyor.token` in the current directory. " "You can get the token from https://ci.appveyor.c...
[ "def", "make_auth_headers", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "\".appveyor.token\"", ")", ":", "raise", "RuntimeError", "(", "\"Please create a file named `.appveyor.token` in the current directory. \"", "\"You can get the token from https://c...
Make the authentication headers needed to use the Appveyor API.
[ "Make", "the", "authentication", "headers", "needed", "to", "use", "the", "Appveyor", "API", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/ci/appveyor-download.py#L15-L28
aburrell/apexpy
ci/appveyor-download.py
get_project_build
def get_project_build(account_project): """Get the details of the latest Appveyor build.""" url = make_url("/projects/{account_project}", account_project=account_project) response = requests.get(url, headers=make_auth_headers()) return response.json()
python
def get_project_build(account_project): """Get the details of the latest Appveyor build.""" url = make_url("/projects/{account_project}", account_project=account_project) response = requests.get(url, headers=make_auth_headers()) return response.json()
[ "def", "get_project_build", "(", "account_project", ")", ":", "url", "=", "make_url", "(", "\"/projects/{account_project}\"", ",", "account_project", "=", "account_project", ")", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "make_auth_...
Get the details of the latest Appveyor build.
[ "Get", "the", "details", "of", "the", "latest", "Appveyor", "build", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/ci/appveyor-download.py#L36-L40
aburrell/apexpy
ci/appveyor-download.py
download_url
def download_url(url, filename, headers): """Download a file from `url` to `filename`.""" ensure_dirs(filename) response = requests.get(url, headers=headers, stream=True) if response.status_code == 200: with open(filename, 'wb') as f: for chunk in response.iter_content(16 * 1024): ...
python
def download_url(url, filename, headers): """Download a file from `url` to `filename`.""" ensure_dirs(filename) response = requests.get(url, headers=headers, stream=True) if response.status_code == 200: with open(filename, 'wb') as f: for chunk in response.iter_content(16 * 1024): ...
[ "def", "download_url", "(", "url", ",", "filename", ",", "headers", ")", ":", "ensure_dirs", "(", "filename", ")", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "headers", ",", "stream", "=", "True", ")", "if", "response", "...
Download a file from `url` to `filename`.
[ "Download", "a", "file", "from", "url", "to", "filename", "." ]
train
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/ci/appveyor-download.py#L80-L87
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.cli_schemata_list
def cli_schemata_list(self, *args): """Display a list of registered schemata""" self.log('Registered schemata languages:', ",".join(sorted(l10n_schemastore.keys()))) self.log('Registered Schemata:', ",".join(sorted(schemastore.keys()))) if '-c' in args or '-config' in args: ...
python
def cli_schemata_list(self, *args): """Display a list of registered schemata""" self.log('Registered schemata languages:', ",".join(sorted(l10n_schemastore.keys()))) self.log('Registered Schemata:', ",".join(sorted(schemastore.keys()))) if '-c' in args or '-config' in args: ...
[ "def", "cli_schemata_list", "(", "self", ",", "*", "args", ")", ":", "self", ".", "log", "(", "'Registered schemata languages:'", ",", "\",\"", ".", "join", "(", "sorted", "(", "l10n_schemastore", ".", "keys", "(", ")", ")", ")", ")", "self", ".", "log",...
Display a list of registered schemata
[ "Display", "a", "list", "of", "registered", "schemata" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L87-L93
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.cli_form
def cli_form(self, *args): """Display a schemata's form definition""" if args[0] == '*': for schema in schemastore: self.log(schema, ':', schemastore[schema]['form'], pretty=True) else: self.log(schemastore[args[0]]['form'], pretty=True)
python
def cli_form(self, *args): """Display a schemata's form definition""" if args[0] == '*': for schema in schemastore: self.log(schema, ':', schemastore[schema]['form'], pretty=True) else: self.log(schemastore[args[0]]['form'], pretty=True)
[ "def", "cli_form", "(", "self", ",", "*", "args", ")", ":", "if", "args", "[", "0", "]", "==", "'*'", ":", "for", "schema", "in", "schemastore", ":", "self", ".", "log", "(", "schema", ",", "':'", ",", "schemastore", "[", "schema", "]", "[", "'fo...
Display a schemata's form definition
[ "Display", "a", "schemata", "s", "form", "definition" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L96-L103
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.cli_schema
def cli_schema(self, *args): """Display a single schema definition""" key = None if len(args) > 1: key = args[1] args = list(args) if '-config' in args or '-c' in args: store = configschemastore try: args.remove('-c') ...
python
def cli_schema(self, *args): """Display a single schema definition""" key = None if len(args) > 1: key = args[1] args = list(args) if '-config' in args or '-c' in args: store = configschemastore try: args.remove('-c') ...
[ "def", "cli_schema", "(", "self", ",", "*", "args", ")", ":", "key", "=", "None", "if", "len", "(", "args", ")", ">", "1", ":", "key", "=", "args", "[", "1", "]", "args", "=", "list", "(", "args", ")", "if", "'-config'", "in", "args", "or", "...
Display a single schema definition
[ "Display", "a", "single", "schema", "definition" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L106-L144
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.cli_forms
def cli_forms(self, *args): """List all available form definitions""" forms = [] missing = [] for key, item in schemastore.items(): if 'form' in item and len(item['form']) > 0: forms.append(key) else: missing.append(key) ...
python
def cli_forms(self, *args): """List all available form definitions""" forms = [] missing = [] for key, item in schemastore.items(): if 'form' in item and len(item['form']) > 0: forms.append(key) else: missing.append(key) ...
[ "def", "cli_forms", "(", "self", ",", "*", "args", ")", ":", "forms", "=", "[", "]", "missing", "=", "[", "]", "for", "key", ",", "item", "in", "schemastore", ".", "items", "(", ")", ":", "if", "'form'", "in", "item", "and", "len", "(", "item", ...
List all available form definitions
[ "List", "all", "available", "form", "definitions" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L147-L160
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.cli_default_perms
def cli_default_perms(self, *args): """Show default permissions for all schemata""" for key, item in schemastore.items(): # self.log(item, pretty=True) if item['schema'].get('no_perms', False): self.log('Schema without permissions:', key) continue...
python
def cli_default_perms(self, *args): """Show default permissions for all schemata""" for key, item in schemastore.items(): # self.log(item, pretty=True) if item['schema'].get('no_perms', False): self.log('Schema without permissions:', key) continue...
[ "def", "cli_default_perms", "(", "self", ",", "*", "args", ")", ":", "for", "key", ",", "item", "in", "schemastore", ".", "items", "(", ")", ":", "# self.log(item, pretty=True)", "if", "item", "[", "'schema'", "]", ".", "get", "(", "'no_perms'", ",", "Fa...
Show default permissions for all schemata
[ "Show", "default", "permissions", "for", "all", "schemata" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L163-L185
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.ready
def ready(self): """Sets up the application after startup.""" self.log('Got', len(schemastore), 'data and', len(configschemastore), 'component schemata.', lvl=debug)
python
def ready(self): """Sets up the application after startup.""" self.log('Got', len(schemastore), 'data and', len(configschemastore), 'component schemata.', lvl=debug)
[ "def", "ready", "(", "self", ")", ":", "self", ".", "log", "(", "'Got'", ",", "len", "(", "schemastore", ")", ",", "'data and'", ",", "len", "(", "configschemastore", ")", ",", "'component schemata.'", ",", "lvl", "=", "debug", ")" ]
Sets up the application after startup.
[ "Sets", "up", "the", "application", "after", "startup", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L188-L192
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.all
def all(self, event): """Return all known schemata to the requesting client""" self.log("Schemarequest for all schemata from", event.user, lvl=debug) response = { 'component': 'hfos.events.schemamanager', 'action': 'all', 'data': l10n_schemas...
python
def all(self, event): """Return all known schemata to the requesting client""" self.log("Schemarequest for all schemata from", event.user, lvl=debug) response = { 'component': 'hfos.events.schemamanager', 'action': 'all', 'data': l10n_schemas...
[ "def", "all", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Schemarequest for all schemata from\"", ",", "event", ".", "user", ",", "lvl", "=", "debug", ")", "response", "=", "{", "'component'", ":", "'hfos.events.schemamanager'", ",", "'a...
Return all known schemata to the requesting client
[ "Return", "all", "known", "schemata", "to", "the", "requesting", "client" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L198-L208
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.get
def get(self, event): """Return a single schema""" self.log("Schemarequest for", event.data, "from", event.user, lvl=debug) if event.data in schemastore: response = { 'component': 'hfos.events.schemamanager', 'action': 'get', ...
python
def get(self, event): """Return a single schema""" self.log("Schemarequest for", event.data, "from", event.user, lvl=debug) if event.data in schemastore: response = { 'component': 'hfos.events.schemamanager', 'action': 'get', ...
[ "def", "get", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Schemarequest for\"", ",", "event", ".", "data", ",", "\"from\"", ",", "event", ".", "user", ",", "lvl", "=", "debug", ")", "if", "event", ".", "data", "in", "schemastore"...
Return a single schema
[ "Return", "a", "single", "schema" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L211-L223
Hackerfleet/hfos
hfos/ui/schemamanager.py
SchemaManager.configuration
def configuration(self, event): """Return all configurable components' schemata""" try: self.log("Schemarequest for all configuration schemata from", event.user.account.name, lvl=debug) response = { 'component': 'hfos.events.schemamanager', ...
python
def configuration(self, event): """Return all configurable components' schemata""" try: self.log("Schemarequest for all configuration schemata from", event.user.account.name, lvl=debug) response = { 'component': 'hfos.events.schemamanager', ...
[ "def", "configuration", "(", "self", ",", "event", ")", ":", "try", ":", "self", ".", "log", "(", "\"Schemarequest for all configuration schemata from\"", ",", "event", ".", "user", ".", "account", ".", "name", ",", "lvl", "=", "debug", ")", "response", "=",...
Return all configurable components' schemata
[ "Return", "all", "configurable", "components", "schemata" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L226-L239
Hackerfleet/hfos
hfos/schemata/base.py
uuid_object
def uuid_object(title="Reference", description="Select an object", default=None, display=True): """Generates a regular expression controlled UUID field""" uuid = { 'pattern': '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{' '4}-[' 'a-fA-F0-9]{4}-[a-fA-F0-9]{12}$', ...
python
def uuid_object(title="Reference", description="Select an object", default=None, display=True): """Generates a regular expression controlled UUID field""" uuid = { 'pattern': '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{' '4}-[' 'a-fA-F0-9]{4}-[a-fA-F0-9]{12}$', ...
[ "def", "uuid_object", "(", "title", "=", "\"Reference\"", ",", "description", "=", "\"Select an object\"", ",", "default", "=", "None", ",", "display", "=", "True", ")", ":", "uuid", "=", "{", "'pattern'", ":", "'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{'", "'4}...
Generates a regular expression controlled UUID field
[ "Generates", "a", "regular", "expression", "controlled", "UUID", "field" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/base.py#L42-L62
Hackerfleet/hfos
hfos/schemata/base.py
base_object
def base_object(name, no_perms=False, has_owner=True, hide_owner=True, has_uuid=True, roles_write=None, roles_read=None, roles_list=None, roles_create=None, all_roles=None): ...
python
def base_object(name, no_perms=False, has_owner=True, hide_owner=True, has_uuid=True, roles_write=None, roles_read=None, roles_list=None, roles_create=None, all_roles=None): ...
[ "def", "base_object", "(", "name", ",", "no_perms", "=", "False", ",", "has_owner", "=", "True", ",", "hide_owner", "=", "True", ",", "has_uuid", "=", "True", ",", "roles_write", "=", "None", ",", "roles_read", "=", "None", ",", "roles_list", "=", "None"...
Generates a basic object with RBAC properties
[ "Generates", "a", "basic", "object", "with", "RBAC", "properties" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/base.py#L65-L172
Hackerfleet/hfos
modules/navdata/hfos/navdata/sensors.py
serial_ports
def serial_ports(): """ Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system Courtesy: Thomas ( http://stackoverflow.com/questions/12090503 /listing-available-com-p...
python
def serial_ports(): """ Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system Courtesy: Thomas ( http://stackoverflow.com/questions/12090503 /listing-available-com-p...
[ "def", "serial_ports", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'win'", ")", ":", "ports", "=", "[", "'COM%s'", "%", "(", "i", "+", "1", ")", "for", "i", "in", "range", "(", "256", ")", "]", "elif", "sys", ".", "pla...
Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system Courtesy: Thomas ( http://stackoverflow.com/questions/12090503 /listing-available-com-ports-with-python )
[ "Lists", "serial", "port", "names" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/sensors.py#L61-L91
Hackerfleet/hfos
modules/navdata/hfos/navdata/sensors.py
Sensors.sensordata
def sensordata(self, event): """ Generates a new reference frame from incoming sensordata :param event: new sensordata to be merged into referenceframe """ if len(self.datatypes) == 0: return data = event.data timestamp = event.timestamp # b...
python
def sensordata(self, event): """ Generates a new reference frame from incoming sensordata :param event: new sensordata to be merged into referenceframe """ if len(self.datatypes) == 0: return data = event.data timestamp = event.timestamp # b...
[ "def", "sensordata", "(", "self", ",", "event", ")", ":", "if", "len", "(", "self", ".", "datatypes", ")", "==", "0", ":", "return", "data", "=", "event", ".", "data", "timestamp", "=", "event", ".", "timestamp", "# bus = event.bus", "# TODO: What about mu...
Generates a new reference frame from incoming sensordata :param event: new sensordata to be merged into referenceframe
[ "Generates", "a", "new", "reference", "frame", "from", "incoming", "sensordata" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/sensors.py#L225-L288
Hackerfleet/hfos
modules/navdata/hfos/navdata/sensors.py
Sensors.navdatapush
def navdatapush(self): """ Pushes the current :referenceframe: out to clients. :return: """ try: self.fireEvent(referenceframe({ 'data': self.referenceframe, 'ages': self.referenceages }), "navdata") self.intervalcount += 1 ...
python
def navdatapush(self): """ Pushes the current :referenceframe: out to clients. :return: """ try: self.fireEvent(referenceframe({ 'data': self.referenceframe, 'ages': self.referenceages }), "navdata") self.intervalcount += 1 ...
[ "def", "navdatapush", "(", "self", ")", ":", "try", ":", "self", ".", "fireEvent", "(", "referenceframe", "(", "{", "'data'", ":", "self", ".", "referenceframe", ",", "'ages'", ":", "self", ".", "referenceages", "}", ")", ",", "\"navdata\"", ")", "self",...
Pushes the current :referenceframe: out to clients. :return:
[ "Pushes", "the", "current", ":", "referenceframe", ":", "out", "to", "clients", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/sensors.py#L290-L318
Hackerfleet/hfos
hfos/tool/backup.py
db_export
def db_export(schema, uuid, object_filter, export_format, filename, pretty, all_schemata, omit): """Export stored objects Warning! This functionality is work in progress and you may destroy live data by using it! Be very careful when using the export/import functionality!""" internal_backup(schema, uu...
python
def db_export(schema, uuid, object_filter, export_format, filename, pretty, all_schemata, omit): """Export stored objects Warning! This functionality is work in progress and you may destroy live data by using it! Be very careful when using the export/import functionality!""" internal_backup(schema, uu...
[ "def", "db_export", "(", "schema", ",", "uuid", ",", "object_filter", ",", "export_format", ",", "filename", ",", "pretty", ",", "all_schemata", ",", "omit", ")", ":", "internal_backup", "(", "schema", ",", "uuid", ",", "object_filter", ",", "export_format", ...
Export stored objects Warning! This functionality is work in progress and you may destroy live data by using it! Be very careful when using the export/import functionality!
[ "Export", "stored", "objects" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/backup.py#L45-L51
Hackerfleet/hfos
hfos/tool/backup.py
db_import
def db_import(ctx, schema, uuid, object_filter, import_format, filename, all_schemata, dry): """Import objects from file Warning! This functionality is work in progress and you may destroy live data by using it! Be very careful when using the export/import functionality!""" import_format = import_form...
python
def db_import(ctx, schema, uuid, object_filter, import_format, filename, all_schemata, dry): """Import objects from file Warning! This functionality is work in progress and you may destroy live data by using it! Be very careful when using the export/import functionality!""" import_format = import_form...
[ "def", "db_import", "(", "ctx", ",", "schema", ",", "uuid", ",", "object_filter", ",", "import_format", ",", "filename", ",", "all_schemata", ",", "dry", ")", ":", "import_format", "=", "import_format", ".", "upper", "(", ")", "with", "open", "(", "filenam...
Import objects from file Warning! This functionality is work in progress and you may destroy live data by using it! Be very careful when using the export/import functionality!
[ "Import", "objects", "from", "file" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/backup.py#L65-L121
Hackerfleet/hfos
modules/wiki/hfos/wiki/wiki.py
Wiki._page_update
def _page_update(self, event): """ Checks if the newly created object is a wikipage.. If so, rerenders the automatic index. :param event: objectchange or objectcreation event """ try: if event.schema == 'wikipage': self._update_index() ...
python
def _page_update(self, event): """ Checks if the newly created object is a wikipage.. If so, rerenders the automatic index. :param event: objectchange or objectcreation event """ try: if event.schema == 'wikipage': self._update_index() ...
[ "def", "_page_update", "(", "self", ",", "event", ")", ":", "try", ":", "if", "event", ".", "schema", "==", "'wikipage'", ":", "self", ".", "_update_index", "(", ")", "except", "Exception", "as", "e", ":", "self", ".", "log", "(", "\"Page creation notifi...
Checks if the newly created object is a wikipage.. If so, rerenders the automatic index. :param event: objectchange or objectcreation event
[ "Checks", "if", "the", "newly", "created", "object", "is", "a", "wikipage", "..", "If", "so", "rerenders", "the", "automatic", "index", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/wiki/hfos/wiki/wiki.py#L73-L86
Hackerfleet/hfos
hfos/launcher.py
drop_privileges
def drop_privileges(uid_name='hfos', gid_name='hfos'): """Attempt to drop privileges and change user to 'hfos' user/group""" if os.getuid() != 0: hfoslog("Not root, cannot drop privileges", lvl=warn, emitter='CORE') return try: # Get the uid/gid from the name running_uid = ...
python
def drop_privileges(uid_name='hfos', gid_name='hfos'): """Attempt to drop privileges and change user to 'hfos' user/group""" if os.getuid() != 0: hfoslog("Not root, cannot drop privileges", lvl=warn, emitter='CORE') return try: # Get the uid/gid from the name running_uid = ...
[ "def", "drop_privileges", "(", "uid_name", "=", "'hfos'", ",", "gid_name", "=", "'hfos'", ")", ":", "if", "os", ".", "getuid", "(", ")", "!=", "0", ":", "hfoslog", "(", "\"Not root, cannot drop privileges\"", ",", "lvl", "=", "warn", ",", "emitter", "=", ...
Attempt to drop privileges and change user to 'hfos' user/group
[ "Attempt", "to", "drop", "privileges", "and", "change", "user", "to", "hfos", "user", "/", "group" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L108-L131
Hackerfleet/hfos
hfos/launcher.py
construct_graph
def construct_graph(args): """Preliminary HFOS application Launcher""" app = Core(args) setup_root(app) if args['debug']: from circuits import Debugger hfoslog("Starting circuits debugger", lvl=warn, emitter='GRAPH') dbg = Debugger().register(app) # TODO: Make these co...
python
def construct_graph(args): """Preliminary HFOS application Launcher""" app = Core(args) setup_root(app) if args['debug']: from circuits import Debugger hfoslog("Starting circuits debugger", lvl=warn, emitter='GRAPH') dbg = Debugger().register(app) # TODO: Make these co...
[ "def", "construct_graph", "(", "args", ")", ":", "app", "=", "Core", "(", "args", ")", "setup_root", "(", "app", ")", "if", "args", "[", "'debug'", "]", ":", "from", "circuits", "import", "Debugger", "hfoslog", "(", "\"Starting circuits debugger\"", ",", "...
Preliminary HFOS application Launcher
[ "Preliminary", "HFOS", "application", "Launcher" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L512-L551
Hackerfleet/hfos
hfos/launcher.py
launch
def launch(run=True, **args): """Bootstrap basics, assemble graph and hand over control to the Core component""" verbosity['console'] = args['log'] if not args['quiet'] else 100 verbosity['global'] = min(args['log'], args['logfileverbosity']) verbosity['file'] = args['logfileverbosity'] if args['do...
python
def launch(run=True, **args): """Bootstrap basics, assemble graph and hand over control to the Core component""" verbosity['console'] = args['log'] if not args['quiet'] else 100 verbosity['global'] = min(args['log'], args['logfileverbosity']) verbosity['file'] = args['logfileverbosity'] if args['do...
[ "def", "launch", "(", "run", "=", "True", ",", "*", "*", "args", ")", ":", "verbosity", "[", "'console'", "]", "=", "args", "[", "'log'", "]", "if", "not", "args", "[", "'quiet'", "]", "else", "100", "verbosity", "[", "'global'", "]", "=", "min", ...
Bootstrap basics, assemble graph and hand over control to the Core component
[ "Bootstrap", "basics", "assemble", "graph", "and", "hand", "over", "control", "to", "the", "Core", "component" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L585-L612
Hackerfleet/hfos
hfos/launcher.py
Core.ready
def ready(self, source): """All components have initialized, set up the component configuration schema-store, run the local server and drop privileges""" from hfos.database import configschemastore configschemastore[self.name] = self.configschema self._start_server() i...
python
def ready(self, source): """All components have initialized, set up the component configuration schema-store, run the local server and drop privileges""" from hfos.database import configschemastore configschemastore[self.name] = self.configschema self._start_server() i...
[ "def", "ready", "(", "self", ",", "source", ")", ":", "from", "hfos", ".", "database", "import", "configschemastore", "configschemastore", "[", "self", ".", "name", "]", "=", "self", ".", "configschema", "self", ".", "_start_server", "(", ")", "if", "not",...
All components have initialized, set up the component configuration schema-store, run the local server and drop privileges
[ "All", "components", "have", "initialized", "set", "up", "the", "component", "configuration", "schema", "-", "store", "run", "the", "local", "server", "and", "drop", "privileges" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L228-L245
Hackerfleet/hfos
hfos/launcher.py
Core.trigger_frontend_build
def trigger_frontend_build(self, event): """Event hook to trigger a new frontend build""" from hfos.database import instance install_frontend(instance=instance, forcerebuild=event.force, install=event.install, developmen...
python
def trigger_frontend_build(self, event): """Event hook to trigger a new frontend build""" from hfos.database import instance install_frontend(instance=instance, forcerebuild=event.force, install=event.install, developmen...
[ "def", "trigger_frontend_build", "(", "self", ",", "event", ")", ":", "from", "hfos", ".", "database", "import", "instance", "install_frontend", "(", "instance", "=", "instance", ",", "forcerebuild", "=", "event", ".", "force", ",", "install", "=", "event", ...
Event hook to trigger a new frontend build
[ "Event", "hook", "to", "trigger", "a", "new", "frontend", "build" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L248-L256
Hackerfleet/hfos
hfos/launcher.py
Core.cli_reload
def cli_reload(self, event): """Experimental call to reload the component tree""" self.log('Reloading all components.') self.update_components(forcereload=True) initialize() from hfos.debugger import cli_compgraph self.fireEvent(cli_compgraph())
python
def cli_reload(self, event): """Experimental call to reload the component tree""" self.log('Reloading all components.') self.update_components(forcereload=True) initialize() from hfos.debugger import cli_compgraph self.fireEvent(cli_compgraph())
[ "def", "cli_reload", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Reloading all components.'", ")", "self", ".", "update_components", "(", "forcereload", "=", "True", ")", "initialize", "(", ")", "from", "hfos", ".", "debugger", "import", ...
Experimental call to reload the component tree
[ "Experimental", "call", "to", "reload", "the", "component", "tree" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L280-L289
Hackerfleet/hfos
hfos/launcher.py
Core.cli_info
def cli_info(self, event): """Provides information about the running instance""" self.log('Instance:', self.instance, 'Dev:', self.development, 'Host:', self.host, 'Port:', self.port, 'Insecure:', self.insecure, 'Front...
python
def cli_info(self, event): """Provides information about the running instance""" self.log('Instance:', self.instance, 'Dev:', self.development, 'Host:', self.host, 'Port:', self.port, 'Insecure:', self.insecure, 'Front...
[ "def", "cli_info", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Instance:'", ",", "self", ".", "instance", ",", "'Dev:'", ",", "self", ".", "development", ",", "'Host:'", ",", "self", ".", "host", ",", "'Port:'", ",", "self", ".", ...
Provides information about the running instance
[ "Provides", "information", "about", "the", "running", "instance" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L299-L307
Hackerfleet/hfos
hfos/launcher.py
Core._start_server
def _start_server(self, *args): """Run the node local server""" self.log("Starting server", args) secure = self.certificate is not None if secure: self.log("Running SSL server with cert:", self.certificate) else: self.log("Running insecure server without ...
python
def _start_server(self, *args): """Run the node local server""" self.log("Starting server", args) secure = self.certificate is not None if secure: self.log("Running SSL server with cert:", self.certificate) else: self.log("Running insecure server without ...
[ "def", "_start_server", "(", "self", ",", "*", "args", ")", ":", "self", ".", "log", "(", "\"Starting server\"", ",", "args", ")", "secure", "=", "self", ".", "certificate", "is", "not", "None", "if", "secure", ":", "self", ".", "log", "(", "\"Running ...
Run the node local server
[ "Run", "the", "node", "local", "server" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L309-L328
Hackerfleet/hfos
hfos/launcher.py
Core.update_components
def update_components(self, forcereload=False, forcerebuild=False, forcecopy=True, install=False): """Check all known entry points for components. If necessary, manage configuration updates""" # TODO: See if we can pull out major parts of the component handling. ...
python
def update_components(self, forcereload=False, forcerebuild=False, forcecopy=True, install=False): """Check all known entry points for components. If necessary, manage configuration updates""" # TODO: See if we can pull out major parts of the component handling. ...
[ "def", "update_components", "(", "self", ",", "forcereload", "=", "False", ",", "forcerebuild", "=", "False", ",", "forcecopy", "=", "True", ",", "install", "=", "False", ")", ":", "# TODO: See if we can pull out major parts of the component handling.", "# They are also...
Check all known entry points for components. If necessary, manage configuration updates
[ "Check", "all", "known", "entry", "points", "for", "components", ".", "If", "necessary", "manage", "configuration", "updates" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L340-L428
Hackerfleet/hfos
hfos/launcher.py
Core._start_frontend
def _start_frontend(self, restart=False): """Check if it is enabled and start the frontend http & websocket""" self.log(self.config, self.config.frontendenabled, lvl=verbose) if self.config.frontendenabled and not self.frontendrunning or restart: self.log("Restarting webfrontend ser...
python
def _start_frontend(self, restart=False): """Check if it is enabled and start the frontend http & websocket""" self.log(self.config, self.config.frontendenabled, lvl=verbose) if self.config.frontendenabled and not self.frontendrunning or restart: self.log("Restarting webfrontend ser...
[ "def", "_start_frontend", "(", "self", ",", "restart", "=", "False", ")", ":", "self", ".", "log", "(", "self", ".", "config", ",", "self", ".", "config", ".", "frontendenabled", ",", "lvl", "=", "verbose", ")", "if", "self", ".", "config", ".", "fro...
Check if it is enabled and start the frontend http & websocket
[ "Check", "if", "it", "is", "enabled", "and", "start", "the", "frontend", "http", "&", "websocket" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L430-L442
Hackerfleet/hfos
hfos/launcher.py
Core._instantiate_components
def _instantiate_components(self, clear=True): """Inspect all loadable components and run them""" if clear: import objgraph from copy import deepcopy from circuits.tools import kill from circuits import Component for comp in self.runningcompon...
python
def _instantiate_components(self, clear=True): """Inspect all loadable components and run them""" if clear: import objgraph from copy import deepcopy from circuits.tools import kill from circuits import Component for comp in self.runningcompon...
[ "def", "_instantiate_components", "(", "self", ",", "clear", "=", "True", ")", ":", "if", "clear", ":", "import", "objgraph", "from", "copy", "import", "deepcopy", "from", "circuits", ".", "tools", "import", "kill", "from", "circuits", "import", "Component", ...
Inspect all loadable components and run them
[ "Inspect", "all", "loadable", "components", "and", "run", "them" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L444-L494
Hackerfleet/hfos
hfos/launcher.py
Core.started
def started(self, component): """Sets up the application after startup.""" self.log("Running.") self.log("Started event origin: ", component, lvl=verbose) populate_user_events() from hfos.events.system import AuthorizedEvents self.log(len(AuthorizedEvents), "authorized ...
python
def started(self, component): """Sets up the application after startup.""" self.log("Running.") self.log("Started event origin: ", component, lvl=verbose) populate_user_events() from hfos.events.system import AuthorizedEvents self.log(len(AuthorizedEvents), "authorized ...
[ "def", "started", "(", "self", ",", "component", ")", ":", "self", ".", "log", "(", "\"Running.\"", ")", "self", ".", "log", "(", "\"Started event origin: \"", ",", "component", ",", "lvl", "=", "verbose", ")", "populate_user_events", "(", ")", "from", "hf...
Sets up the application after startup.
[ "Sets", "up", "the", "application", "after", "startup", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L496-L509
Hackerfleet/hfos
hfos/tool/user.py
user
def user(ctx, username, password): """[GROUP] User management operations""" ctx.obj['username'] = username ctx.obj['password'] = password
python
def user(ctx, username, password): """[GROUP] User management operations""" ctx.obj['username'] = username ctx.obj['password'] = password
[ "def", "user", "(", "ctx", ",", "username", ",", "password", ")", ":", "ctx", ".", "obj", "[", "'username'", "]", "=", "username", "ctx", ".", "obj", "[", "'password'", "]", "=", "password" ]
[GROUP] User management operations
[ "[", "GROUP", "]", "User", "management", "operations" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L41-L45
Hackerfleet/hfos
hfos/tool/user.py
_create_user
def _create_user(ctx): """Internal method to create a normal user""" username, passhash = _get_credentials(ctx.obj['username'], ctx.obj['password'], ctx.obj['db']) if ctx.obj['db'].objectmodels['user'].count({'name': usern...
python
def _create_user(ctx): """Internal method to create a normal user""" username, passhash = _get_credentials(ctx.obj['username'], ctx.obj['password'], ctx.obj['db']) if ctx.obj['db'].objectmodels['user'].count({'name': usern...
[ "def", "_create_user", "(", "ctx", ")", ":", "username", ",", "passhash", "=", "_get_credentials", "(", "ctx", ".", "obj", "[", "'username'", "]", ",", "ctx", ".", "obj", "[", "'password'", "]", ",", "ctx", ".", "obj", "[", "'db'", "]", ")", "if", ...
Internal method to create a normal user
[ "Internal", "method", "to", "create", "a", "normal", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L48-L66
Hackerfleet/hfos
hfos/tool/user.py
create_user
def create_user(ctx): """Creates a new local user""" try: new_user = _create_user(ctx) new_user.save() log("Done") except KeyError: log('User already exists', lvl=warn)
python
def create_user(ctx): """Creates a new local user""" try: new_user = _create_user(ctx) new_user.save() log("Done") except KeyError: log('User already exists', lvl=warn)
[ "def", "create_user", "(", "ctx", ")", ":", "try", ":", "new_user", "=", "_create_user", "(", "ctx", ")", "new_user", ".", "save", "(", ")", "log", "(", "\"Done\"", ")", "except", "KeyError", ":", "log", "(", "'User already exists'", ",", "lvl", "=", "...
Creates a new local user
[ "Creates", "a", "new", "local", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L71-L80
Hackerfleet/hfos
hfos/tool/user.py
create_admin
def create_admin(ctx): """Creates a new local user and assigns admin role""" try: admin = _create_user(ctx) admin.roles.append('admin') admin.save() log("Done") except KeyError: log('User already exists', lvl=warn)
python
def create_admin(ctx): """Creates a new local user and assigns admin role""" try: admin = _create_user(ctx) admin.roles.append('admin') admin.save() log("Done") except KeyError: log('User already exists', lvl=warn)
[ "def", "create_admin", "(", "ctx", ")", ":", "try", ":", "admin", "=", "_create_user", "(", "ctx", ")", "admin", ".", "roles", ".", "append", "(", "'admin'", ")", "admin", ".", "save", "(", ")", "log", "(", "\"Done\"", ")", "except", "KeyError", ":",...
Creates a new local user and assigns admin role
[ "Creates", "a", "new", "local", "user", "and", "assigns", "admin", "role" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L85-L95
Hackerfleet/hfos
hfos/tool/user.py
delete_user
def delete_user(ctx, yes): """Delete a local user""" if ctx.obj['username'] is None: username = _ask("Please enter username:") else: username = ctx.obj['username'] del_user = ctx.obj['db'].objectmodels['user'].find_one({'name': username}) if yes or _ask('Confirm deletion', default=...
python
def delete_user(ctx, yes): """Delete a local user""" if ctx.obj['username'] is None: username = _ask("Please enter username:") else: username = ctx.obj['username'] del_user = ctx.obj['db'].objectmodels['user'].find_one({'name': username}) if yes or _ask('Confirm deletion', default=...
[ "def", "delete_user", "(", "ctx", ",", "yes", ")", ":", "if", "ctx", ".", "obj", "[", "'username'", "]", "is", "None", ":", "username", "=", "_ask", "(", "\"Please enter username:\"", ")", "else", ":", "username", "=", "ctx", ".", "obj", "[", "'usernam...
Delete a local user
[ "Delete", "a", "local", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L102-L118
Hackerfleet/hfos
hfos/tool/user.py
change_password
def change_password(ctx): """Change password of an existing user""" username, passhash = _get_credentials(ctx.obj['username'], ctx.obj['password'], ctx.obj['db']) change_user = ctx.obj['db'].objectmodels['user'].find_one({...
python
def change_password(ctx): """Change password of an existing user""" username, passhash = _get_credentials(ctx.obj['username'], ctx.obj['password'], ctx.obj['db']) change_user = ctx.obj['db'].objectmodels['user'].find_one({...
[ "def", "change_password", "(", "ctx", ")", ":", "username", ",", "passhash", "=", "_get_credentials", "(", "ctx", ".", "obj", "[", "'username'", "]", ",", "ctx", ".", "obj", "[", "'password'", "]", ",", "ctx", ".", "obj", "[", "'db'", "]", ")", "chan...
Change password of an existing user
[ "Change", "password", "of", "an", "existing", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L123-L140
Hackerfleet/hfos
hfos/tool/user.py
list_users
def list_users(ctx, search, uuid, active): """List all locally known users""" users = ctx.obj['db'].objectmodels['user'] for found_user in users.find(): if not search or (search and search in found_user.name): # TODO: Not 2.x compatible print(found_user.name, end=' ' if act...
python
def list_users(ctx, search, uuid, active): """List all locally known users""" users = ctx.obj['db'].objectmodels['user'] for found_user in users.find(): if not search or (search and search in found_user.name): # TODO: Not 2.x compatible print(found_user.name, end=' ' if act...
[ "def", "list_users", "(", "ctx", ",", "search", ",", "uuid", ",", "active", ")", ":", "users", "=", "ctx", ".", "obj", "[", "'db'", "]", ".", "objectmodels", "[", "'user'", "]", "for", "found_user", "in", "users", ".", "find", "(", ")", ":", "if", ...
List all locally known users
[ "List", "all", "locally", "known", "users" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L151-L165
Hackerfleet/hfos
hfos/tool/user.py
disable
def disable(ctx): """Disable an existing user""" if ctx.obj['username'] is None: log('Specify the username with "iso db user --username ..."') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ 'name': ctx.obj['username'] }) change_user.active = False c...
python
def disable(ctx): """Disable an existing user""" if ctx.obj['username'] is None: log('Specify the username with "iso db user --username ..."') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ 'name': ctx.obj['username'] }) change_user.active = False c...
[ "def", "disable", "(", "ctx", ")", ":", "if", "ctx", ".", "obj", "[", "'username'", "]", "is", "None", ":", "log", "(", "'Specify the username with \"iso db user --username ...\"'", ")", "return", "change_user", "=", "ctx", ".", "obj", "[", "'db'", "]", ".",...
Disable an existing user
[ "Disable", "an", "existing", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L170-L183
Hackerfleet/hfos
hfos/tool/user.py
enable
def enable(ctx): """Enable an existing user""" if ctx.obj['username'] is None: log('Specify the username with "iso db user --username ..."') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ 'name': ctx.obj['username'] }) change_user.active = True chan...
python
def enable(ctx): """Enable an existing user""" if ctx.obj['username'] is None: log('Specify the username with "iso db user --username ..."') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ 'name': ctx.obj['username'] }) change_user.active = True chan...
[ "def", "enable", "(", "ctx", ")", ":", "if", "ctx", ".", "obj", "[", "'username'", "]", "is", "None", ":", "log", "(", "'Specify the username with \"iso db user --username ...\"'", ")", "return", "change_user", "=", "ctx", ".", "obj", "[", "'db'", "]", ".", ...
Enable an existing user
[ "Enable", "an", "existing", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L188-L201
Hackerfleet/hfos
hfos/tool/user.py
add_role
def add_role(ctx, role): """Grant a role to an existing user""" if role is None: log('Specify the role with --role') return if ctx.obj['username'] is None: log('Specify the username with --username') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ ...
python
def add_role(ctx, role): """Grant a role to an existing user""" if role is None: log('Specify the role with --role') return if ctx.obj['username'] is None: log('Specify the username with --username') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ ...
[ "def", "add_role", "(", "ctx", ",", "role", ")", ":", "if", "role", "is", "None", ":", "log", "(", "'Specify the role with --role'", ")", "return", "if", "ctx", ".", "obj", "[", "'username'", "]", "is", "None", ":", "log", "(", "'Specify the username with ...
Grant a role to an existing user
[ "Grant", "a", "role", "to", "an", "existing", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L207-L225
andychase/reparse
reparse/tools/expression_checker.py
check_expression
def check_expression(testing_framework, expression_dict): """ >>> class mock_framework: ... def assertIn(self, item, list, msg="Failed asserting item is in list"): ... if item not in list: raise Exception(msg) ... def assertTrue(self, value, msg="Failed asserting true"): ... if not v...
python
def check_expression(testing_framework, expression_dict): """ >>> class mock_framework: ... def assertIn(self, item, list, msg="Failed asserting item is in list"): ... if item not in list: raise Exception(msg) ... def assertTrue(self, value, msg="Failed asserting true"): ... if not v...
[ "def", "check_expression", "(", "testing_framework", ",", "expression_dict", ")", ":", "expression_sub", "=", "get_expression_sub", "(", ")", "for", "expression_type_name", ",", "expression_type", "in", "expression_dict", ".", "items", "(", ")", ":", "for", "name", ...
>>> class mock_framework: ... def assertIn(self, item, list, msg="Failed asserting item is in list"): ... if item not in list: raise Exception(msg) ... def assertTrue(self, value, msg="Failed asserting true"): ... if not value: raise Exception(msg) ... def assertFalse(self, value, msg)...
[ ">>>", "class", "mock_framework", ":", "...", "def", "assertIn", "(", "self", "item", "list", "msg", "=", "Failed", "asserting", "item", "is", "in", "list", ")", ":", "...", "if", "item", "not", "in", "list", ":", "raise", "Exception", "(", "msg", ")",...
train
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/tools/expression_checker.py#L25-L48
Hackerfleet/hfos
modules/project/hfos/project/projectservice.py
ProjectService._get_future_tasks
def _get_future_tasks(self): """Assemble a list of future alerts""" self.alerts = {} now = std_now() for task in objectmodels['task'].find({'alert_time': {'$gt': now}}): self.alerts[task.alert_time] = task self.log('Found', len(self.alerts), 'future tasks')
python
def _get_future_tasks(self): """Assemble a list of future alerts""" self.alerts = {} now = std_now() for task in objectmodels['task'].find({'alert_time': {'$gt': now}}): self.alerts[task.alert_time] = task self.log('Found', len(self.alerts), 'future tasks')
[ "def", "_get_future_tasks", "(", "self", ")", ":", "self", ".", "alerts", "=", "{", "}", "now", "=", "std_now", "(", ")", "for", "task", "in", "objectmodels", "[", "'task'", "]", ".", "find", "(", "{", "'alert_time'", ":", "{", "'$gt'", ":", "now", ...
Assemble a list of future alerts
[ "Assemble", "a", "list", "of", "future", "alerts" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/project/hfos/project/projectservice.py#L69-L78
Hackerfleet/hfos
modules/project/hfos/project/projectservice.py
ProjectService.check_alerts
def check_alerts(self): """Periodical check to issue due alerts""" alerted = [] for alert_time, task in self.alerts.items(): task_time = dateutil.parser.parse(alert_time) if task_time < get_time(): self.log('Alerting about task now:', task) ...
python
def check_alerts(self): """Periodical check to issue due alerts""" alerted = [] for alert_time, task in self.alerts.items(): task_time = dateutil.parser.parse(alert_time) if task_time < get_time(): self.log('Alerting about task now:', task) ...
[ "def", "check_alerts", "(", "self", ")", ":", "alerted", "=", "[", "]", "for", "alert_time", ",", "task", "in", "self", ".", "alerts", ".", "items", "(", ")", ":", "task_time", "=", "dateutil", ".", "parser", ".", "parse", "(", "alert_time", ")", "if...
Periodical check to issue due alerts
[ "Periodical", "check", "to", "issue", "due", "alerts" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/project/hfos/project/projectservice.py#L103-L122
Hackerfleet/hfos
modules/busrepeater/hfos/busrepeater/busrepeater.py
BusRepeater.read
def read(self, data): """Handles incoming raw sensor data and broadcasts it to specified udp servers and connected tcp clients :param data: NMEA raw sentences incoming data """ self.log('Received NMEA data:', data, lvl=debug) # self.log(data, pretty=True) if sel...
python
def read(self, data): """Handles incoming raw sensor data and broadcasts it to specified udp servers and connected tcp clients :param data: NMEA raw sentences incoming data """ self.log('Received NMEA data:', data, lvl=debug) # self.log(data, pretty=True) if sel...
[ "def", "read", "(", "self", ",", "data", ")", ":", "self", ".", "log", "(", "'Received NMEA data:'", ",", "data", ",", "lvl", "=", "debug", ")", "# self.log(data, pretty=True)", "if", "self", ".", "_tcp_socket", "is", "not", "None", "and", "len", "(", "s...
Handles incoming raw sensor data and broadcasts it to specified udp servers and connected tcp clients :param data: NMEA raw sentences incoming data
[ "Handles", "incoming", "raw", "sensor", "data", "and", "broadcasts", "it", "to", "specified", "udp", "servers", "and", "connected", "tcp", "clients", ":", "param", "data", ":", "NMEA", "raw", "sentences", "incoming", "data" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/busrepeater/hfos/busrepeater/busrepeater.py#L130-L163
Hackerfleet/hfos
hfos/tool/misc.py
cmdmap
def cmdmap(xdot): """Generates a command map""" # TODO: Integrate the output into documentation from copy import copy def print_commands(command, map_output, groups=None, depth=0): if groups is None: groups = [] if 'commands' in command.__dict__: if len(groups) ...
python
def cmdmap(xdot): """Generates a command map""" # TODO: Integrate the output into documentation from copy import copy def print_commands(command, map_output, groups=None, depth=0): if groups is None: groups = [] if 'commands' in command.__dict__: if len(groups) ...
[ "def", "cmdmap", "(", "xdot", ")", ":", "# TODO: Integrate the output into documentation", "from", "copy", "import", "copy", "def", "print_commands", "(", "command", ",", "map_output", ",", "groups", "=", "None", ",", "depth", "=", "0", ")", ":", "if", "groups...
Generates a command map
[ "Generates", "a", "command", "map" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/misc.py#L47-L88
Hackerfleet/hfos
hfos/tool/templates.py
format_template
def format_template(template, content): """Render a given pystache template with given content""" import pystache result = u"" if True: # try: result = pystache.render(template, content, string_encoding='utf-8') # except (ValueError, KeyError) as e: # print("Templating error: %s...
python
def format_template(template, content): """Render a given pystache template with given content""" import pystache result = u"" if True: # try: result = pystache.render(template, content, string_encoding='utf-8') # except (ValueError, KeyError) as e: # print("Templating error: %s...
[ "def", "format_template", "(", "template", ",", "content", ")", ":", "import", "pystache", "result", "=", "u\"\"", "if", "True", ":", "# try:", "result", "=", "pystache", ".", "render", "(", "template", ",", "content", ",", "string_encoding", "=", "'utf-8'",...
Render a given pystache template with given content
[ "Render", "a", "given", "pystache", "template", "with", "given", "content" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L27-L39
Hackerfleet/hfos
hfos/tool/templates.py
format_template_file
def format_template_file(filename, content): """Render a given pystache template file with given content""" with open(filename, 'r') as f: template = f.read() if type(template) != str: template = template.decode('utf-8') return format_template(template, content)
python
def format_template_file(filename, content): """Render a given pystache template file with given content""" with open(filename, 'r') as f: template = f.read() if type(template) != str: template = template.decode('utf-8') return format_template(template, content)
[ "def", "format_template_file", "(", "filename", ",", "content", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "template", "=", "f", ".", "read", "(", ")", "if", "type", "(", "template", ")", "!=", "str", ":", "template",...
Render a given pystache template file with given content
[ "Render", "a", "given", "pystache", "template", "file", "with", "given", "content" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L42-L50
Hackerfleet/hfos
hfos/tool/templates.py
write_template_file
def write_template_file(source, target, content): """Write a new file from a given pystache template file and content""" # print(formatTemplateFile(source, content)) print(target) data = format_template_file(source, content) with open(target, 'w') as f: for line in data: if type...
python
def write_template_file(source, target, content): """Write a new file from a given pystache template file and content""" # print(formatTemplateFile(source, content)) print(target) data = format_template_file(source, content) with open(target, 'w') as f: for line in data: if type...
[ "def", "write_template_file", "(", "source", ",", "target", ",", "content", ")", ":", "# print(formatTemplateFile(source, content))", "print", "(", "target", ")", "data", "=", "format_template_file", "(", "source", ",", "content", ")", "with", "open", "(", "target...
Write a new file from a given pystache template file and content
[ "Write", "a", "new", "file", "from", "a", "given", "pystache", "template", "file", "and", "content" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L53-L63
Hackerfleet/hfos
hfos/tool/templates.py
insert_nginx_service
def insert_nginx_service(definition): # pragma: no cover """Insert a new nginx service definition""" config_file = '/etc/nginx/sites-available/hfos.conf' splitter = "### SERVICE DEFINITIONS ###" with open(config_file, 'r') as f: old_config = "".join(f.readlines()) pprint(old_config) ...
python
def insert_nginx_service(definition): # pragma: no cover """Insert a new nginx service definition""" config_file = '/etc/nginx/sites-available/hfos.conf' splitter = "### SERVICE DEFINITIONS ###" with open(config_file, 'r') as f: old_config = "".join(f.readlines()) pprint(old_config) ...
[ "def", "insert_nginx_service", "(", "definition", ")", ":", "# pragma: no cover", "config_file", "=", "'/etc/nginx/sites-available/hfos.conf'", "splitter", "=", "\"### SERVICE DEFINITIONS ###\"", "with", "open", "(", "config_file", ",", "'r'", ")", "as", "f", ":", "old_...
Insert a new nginx service definition
[ "Insert", "a", "new", "nginx", "service", "definition" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L66-L99
Hackerfleet/hfos
hfos/tool/rbac.py
rbac
def rbac(ctx, schema, object_filter, action, role, all_schemata): """[GROUP] Role based access control""" database = ctx.obj['db'] if schema is None: if all_schemata is False: log('No schema given. Read the RBAC group help', lvl=warn) sys.exit() else: sc...
python
def rbac(ctx, schema, object_filter, action, role, all_schemata): """[GROUP] Role based access control""" database = ctx.obj['db'] if schema is None: if all_schemata is False: log('No schema given. Read the RBAC group help', lvl=warn) sys.exit() else: sc...
[ "def", "rbac", "(", "ctx", ",", "schema", ",", "object_filter", ",", "action", ",", "role", ",", "all_schemata", ")", ":", "database", "=", "ctx", ".", "obj", "[", "'db'", "]", "if", "schema", "is", "None", ":", "if", "all_schemata", "is", "False", "...
[GROUP] Role based access control
[ "[", "GROUP", "]", "Role", "based", "access", "control" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L42-L73
Hackerfleet/hfos
hfos/tool/rbac.py
add_action_role
def add_action_role(ctx): """Adds a role to an action on objects""" objects = ctx.obj['objects'] action = ctx.obj['action'] role = ctx.obj['role'] if action is None or role is None: log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn) r...
python
def add_action_role(ctx): """Adds a role to an action on objects""" objects = ctx.obj['objects'] action = ctx.obj['action'] role = ctx.obj['role'] if action is None or role is None: log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn) r...
[ "def", "add_action_role", "(", "ctx", ")", ":", "objects", "=", "ctx", ".", "obj", "[", "'objects'", "]", "action", "=", "ctx", ".", "obj", "[", "'action'", "]", "role", "=", "ctx", ".", "obj", "[", "'role'", "]", "if", "action", "is", "None", "or"...
Adds a role to an action on objects
[ "Adds", "a", "role", "to", "an", "action", "on", "objects" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L78-L94
Hackerfleet/hfos
hfos/tool/rbac.py
del_action_role
def del_action_role(ctx): """Deletes a role from an action on objects""" objects = ctx.obj['objects'] action = ctx.obj['action'] role = ctx.obj['role'] if action is None or role is None: log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn) ...
python
def del_action_role(ctx): """Deletes a role from an action on objects""" objects = ctx.obj['objects'] action = ctx.obj['action'] role = ctx.obj['role'] if action is None or role is None: log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn) ...
[ "def", "del_action_role", "(", "ctx", ")", ":", "objects", "=", "ctx", ".", "obj", "[", "'objects'", "]", "action", "=", "ctx", ".", "obj", "[", "'action'", "]", "role", "=", "ctx", ".", "obj", "[", "'role'", "]", "if", "action", "is", "None", "or"...
Deletes a role from an action on objects
[ "Deletes", "a", "role", "from", "an", "action", "on", "objects" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L99-L115