text stringlengths 81 112k |
|---|
Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object.
def set_current(self, current):
"""
Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object.
... |
Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonForm`):
Form object to override `self.o... |
Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands.
def set_client_cmd(self, *args):
"""
Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands.
"""
self.client_cmd.update(args)
self.... |
Creates new permissions.
def run(self):
"""
Creates new permissions.
"""
from pyoko.lib.utils import get_object_from_path
from zengine.config import settings
model = get_object_from_path(settings.PERMISSION_MODEL)
perm_provider = get_object_from_path(settings.PER... |
Creates user, encrypts password.
def run(self):
"""
Creates user, encrypts password.
"""
from zengine.models import User
user = User(username=self.manager.args.username, superuser=self.manager.args.super)
user.set_password(self.manager.args.password)
user.save()
... |
Starts a development server for the zengine application
def run(self):
"""
Starts a development server for the zengine application
"""
print("Development server started on http://%s:%s. \n\nPress Ctrl+C to stop\n" % (
self.manager.args.addr,
self.manager.args.por... |
runs the tornado/websockets based test server
def run_with_tornado(self):
"""
runs the tornado/websockets based test server
"""
from zengine.tornado_server.server import runserver
runserver(self.manager.args.addr, int(self.manager.args.port)) |
runs the falcon/http based test server
def run_with_falcon(self):
"""
runs the falcon/http based test server
"""
from wsgiref import simple_server
from zengine.server import app
httpd = simple_server.make_server(self.manager.args.addr, int(self.manager.args.port), app)
... |
Starts a development server for the zengine application
def run(self):
"""
Starts a development server for the zengine application
"""
from zengine.wf_daemon import run_workers, Worker
worker_count = int(self.manager.args.workers or 1)
if not self.manager.args.daemonize... |
Prepare a helper dictionary for the domain to temporarily hold some information.
def _prepare_domain(mapping):
"""Prepare a helper dictionary for the domain to temporarily hold some information."""
# Parse the domain-directory mapping
try:
domain, dir = mapping.split(':')
ex... |
Check that all domains specified in the settings was provided in the options.
def _validate_domains(domains):
"""Check that all domains specified in the settings was provided in the options."""
missing = set(settings.TRANSLATION_DOMAINS.keys()) - set(domains.keys())
if missing:
prin... |
Extract the translations into `.pot` files
def _extract_translations(self, domains):
"""Extract the translations into `.pot` files"""
for domain, options in domains.items():
# Create the extractor
extractor = babel_frontend.extract_messages()
extractor.initialize_opt... |
Update or initialize the `.po` translation files
def _init_update_po_files(self, domains):
"""Update or initialize the `.po` translation files"""
for language in settings.TRANSLATIONS:
for domain, options in domains.items():
if language == options['default']: continue # Def... |
Remove the temporary '.pot' files that were created for the domains.
def _cleanup(self, domains):
"""Remove the temporary '.pot' files that were created for the domains."""
for option in domains.values():
try:
os.remove(option['pot'])
except (IOError, OSError):
... |
read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf
def run(self):
"""
read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf
"""
from zengine.lib.cache import WFSpecNa... |
load xml from given path
Args:
path: diagram path
Returns:
def get_wf_from_path(self, path):
"""
load xml from given path
Args:
path: diagram path
Returns:
"""
with open(path) as fp:
content = fp.read()
retur... |
Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file
def get_workflows(self):
"""
Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
... |
The model or models are checked for migrations that need to be done.
Solr is also checked.
def check_migration_and_solr(self):
"""
The model or models are checked for migrations that need to be done.
Solr is also checked.
"""
from pyoko.db.schema_update impor... |
Redis checks the connection
It displays on the screen whether or not you have a connection.
def check_redis():
"""
Redis checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import cache
fr... |
Riak checks the connection
It displays on the screen whether or not you have a connection.
def check_riak():
"""
Riak checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import client
from... |
RabbitMQ checks the connection
It displays on the screen whether or not you have a connection.
def check_mq_connection(self):
"""
RabbitMQ checks the connection
It displays on the screen whether or not you have a connection.
"""
import pika
from zengine.client_qu... |
It brings the environment variables to the screen.
The user checks to see if they are using the correct variables.
def check_encoding_and_env():
"""
It brings the environment variables to the screen.
The user checks to see if they are using the correct variables.
"""
imp... |
Finds if the game is over.
:type: position: Board
:rtype: bool
def no_moves(position):
"""
Finds if the game is over.
:type: position: Board
:rtype: bool
"""
return position.no_moves(color.white) \
or position.no_moves(color.black) |
Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool
def is_checkmate(position, input_color):
"""
Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool
"""
return position.no_moves... |
Handles pagination of object listings.
Args:
current_page int:
Current page number
query_set (:class:`QuerySet<pyoko:pyoko.db.queryset.QuerySet>`):
Object listing queryset.
per_page int:
Objects per page.
Returns:
QuerySet object, pagination ... |
Creates a message for the given channel.
.. code-block:: python
# request:
{
'view':'_zops_create_message',
'message': {
'channel': key, # of channel
'body': string, # message text.,
'type': int, # zengine.messa... |
Initial display of channel content.
Returns channel description, members, no of members, last 20 messages etc.
.. code-block:: python
# request:
{
'view':'_zops_show_channel',
'key': key,
}
# response:
{
'chann... |
Get old messages for a channel. 20 messages per request
.. code-block:: python
# request:
{
'view':'_zops_channel_history,
'channel_key': key,
'timestamp': datetime, # timestamp data of oldest shown message
}
... |
Push timestamp of latest message of an ACTIVE channel.
This view should be called with timestamp of latest message;
- When user opens (clicks on) a channel.
- Periodically (eg: setInterval for 15secs) while user staying in a channel.
.. code-block:: python
# request:
{
... |
List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{'name': string, # name of channel
... |
Number of unread messages for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_count',
}
# response:
{
'status': 'OK',
'code': 200,
'notifications': ... |
Returns last N notifications for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_messages',
'amount': int, # Optional, defaults to 8
}
# response:
{
'status': 'OK',... |
Create a public channel. Can be a broadcast channel or normal chat room.
Chat room and broadcast distinction will be made at user subscription phase.
.. code-block:: python
# request:
{
'view':'_zops_create_channel',
'name': string,
... |
Subscribe member(s) to a channel
.. code-block:: python
# request:
{
'view':'_zops_add_members',
'channel_key': key,
'read_only': boolean, # true if this is a Broadcast channel,
# false if it's a... |
Subscribe users of a given unit to given channel
JSON API:
.. code-block:: python
# request:
{
'view':'_zops_add_unit_to_channel',
'unit_key': key,
'channel_key': key,
'read_only': ... |
Search users for adding to a public room
or creating one to one direct messaging
.. code-block:: python
# request:
{
'view':'_zops_search_user',
'query': string,
}
# response:
{
'... |
Search on units for subscribing it's users to a channel
.. code-block:: python
# request:
{
'view':'_zops_search_unit',
'query': string,
}
# response:
{
'results': [('name', 'key'), ],
... |
Create a One-To-One channel between current and selected user.
.. code-block:: python
# request:
{
'view':'_zops_create_direct_channel',
'user_key': key,
}
# response:
{
'description': string,
'no_of_members': ... |
Search in messages. If "channel_key" given, search will be limited to that channel,
otherwise search will be performed on all of user's subscribed channels.
.. code-block:: python
# request:
{
'view':'_zops_search_unit,
'channel_key': key,
... |
Delete a channel
.. code-block:: python
# request:
{
'view':'_zops_delete_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
'code': 200
}
def d... |
Update channel name or description
.. code-block:: python
# request:
{
'view':'_zops_edit_channel,
'channel_key': key,
'name': string,
'description': string,
}
# response:
... |
Pin a channel to top of channel list
.. code-block:: python
# request:
{
'view':'_zops_pin_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
'code': 200
... |
Delete a message
.. code-block:: python
# request:
{
'view':'_zops_delete_message,
'message_key': key,
}
# response:
{
'key': key,
'status': 'OK',
'code': ... |
Edit a message a user own.
.. code-block:: python
# request:
{
'view':'_zops_edit_message',
'message': {
'body': string, # message text
'key': key
}
}
# response:
{
'status': string,... |
Flag inappropriate messages
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'message_key': key,
}
# response:
{
'
'status': 'Created',
'code': 201,
}
def flag_message(current):
... |
remove flag of a message
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'key': key,
}
# response:
{
'
'status': 'OK',
'code': 200,
}
def unflag_message(current):
"""
remov... |
Returns applicable actions for current user for given message key
.. code-block:: python
# request:
{
'view':'_zops_get_message_actions',
'key': key,
}
# response:
{
'actions':[('name_string', 'cmd_string'),]
'status': str... |
Favorite a message
.. code-block:: python
# request:
{
'view':'_zops_add_to_favorites,
'key': key,
}
# response:
{
'status': 'Created',
'code': 201
'favorite_key': key
}
def add_to_favor... |
Remove a message from favorites
.. code-block:: python
# request:
{
'view':'_zops_remove_from_favorites,
'key': key,
}
# response:
{
'status': 'OK',
'code': 200
}
def remove_from_favorites(current):... |
List user's favorites. If "channel_key" given, will return favorites belong to that channel.
.. code-block:: python
# request:
{
'view':'_zops_list_favorites,
'channel_key': key,
}
# response:
{
'status': 'OK',
... |
Creates a direct messaging channel between two user
Args:
initiator: User, who want's to make first contact
receiver: User, other party
Returns:
(Channel, receiver_name)
def get_or_create_direct_channel(cls, initiator_key, receiver_key):
"""
Create... |
Creates MQ exchange for this channel
Needs to be defined only once.
def create_exchange(self):
"""
Creates MQ exchange for this channel
Needs to be defined only once.
"""
mq_channel = self._connect_mq()
mq_channel.exchange_declare(exchange=self.code_name,
... |
Deletes MQ exchange for this channel
Needs to be defined only once.
def delete_exchange(self):
"""
Deletes MQ exchange for this channel
Needs to be defined only once.
"""
mq_channel = self._connect_mq()
mq_channel.exchange_delete(exchange=self.code_name) |
serialized form for channel listing
def get_channel_listing(self):
"""
serialized form for channel listing
"""
return {'name': self.name,
'key': self.channel.key,
'type': self.channel.typ,
'read_only': self.read_only,
'is_... |
Creates user's private exchange
Actually user's private channel needed to be defined only once,
and this should be happened when user first created.
But since this has a little performance cost,
to be safe we always call it before binding to the channel we currently subscribe
def creat... |
Binds (subscribes) users private exchange to channel exchange
Automatically called at creation of subscription record.
def bind_to_channel(self):
"""
Binds (subscribes) users private exchange to channel exchange
Automatically called at creation of subscription record.
"""
... |
Serializes message for given user.
Note:
Should be called before first save(). Otherwise "is_update" will get wrong value.
Args:
user: User object
Returns:
Dict. JSON serialization ready dictionary object
def serialize(self, user=None):
"""
... |
Re-publishes updated message
def _republish(self):
"""
Re-publishes updated message
"""
mq_channel = self.channel._connect_mq()
mq_channel.basic_publish(exchange=self.channel.key, routing_key='',
body=json.dumps(self.serialize())) |
Provide a reasonable default crawl name using the user name and date
def defaultCrawlId():
"""
Provide a reasonable default crawl name using the user name and date
"""
timestamp = datetime.now().isoformat().replace(':', '_')
user = getuser()
return '_'.join(('crawl', user, timestamp)) |
Run Nutch command using REST API.
def main(argv=None):
"""Run Nutch command using REST API."""
global Verbose, Mock
if argv is None:
argv = sys.argv
if len(argv) < 5: die('Bad args')
try:
opts, argv = getopt.getopt(argv[1:], 'hs:p:mv',
['help', 'server=', 'port=', 'mock',... |
Call the Nutch Server, do some error checking, and return the response.
:param verb: One of nutch.RequestVerbs
:param servicePath: path component of URL to append to endpoint, e.g. '/config'
:param data: Data to attach to this request
:param headers: headers to attach to this request, d... |
Create a new named (cid) configuration from a parameter dictionary (config_data).
def create(self, cid, configData):
"""
Create a new named (cid) configuration from a parameter dictionary (config_data).
"""
configArgs = {'configId': cid, 'params': configData, 'force': True}
cid ... |
Return list of jobs at this endpoint.
Call get(allJobs=True) to see all jobs, not just the ones managed by this Client
def list(self, allJobs=False):
"""
Return list of jobs at this endpoint.
Call get(allJobs=True) to see all jobs, not just the ones managed by this Client
"""
... |
Create a job given a command
:param command: Nutch command, one of nutch.LegalJobs
:param args: Additional arguments to pass to the job
:return: The created Job
def create(self, command, **args):
"""
Create a job given a command
:param command: Nutch command, one of nutc... |
:param seed: A Seed object (this or urlDir must be specified)
:param urlDir: The directory on the server containing the seed list (this or urlDir must be specified)
:param args: Extra arguments for the job
:return: a created Job object
def inject(self, seed=None, urlDir=None, **args):
"... |
Create a new named (sid) Seed from a list of seed URLs
:param sid: the name to assign to the new seed list
:param seedList: the list of seeds to use
:return: the created Seed object
def create(self, sid, seedList):
"""
Create a new named (sid) Seed from a list of seed URLs
... |
Create a new named (sid) Seed from a file containing URLs
It's assumed URLs are whitespace seperated.
:param sid: the name to assign to the new seed list
:param filename: the name of the file that contains URLs
:return: the created Seed object
def createFromFile(self, sid, filename):
... |
Given a completed job, start the next job in the round, or return None
:param nextRound: whether to start jobs from the next round if the current round is completed.
:return: the newly started Job, or None if no job was started
def _nextJob(self, job, nextRound=True):
"""
Given a compl... |
Check the status of the current job, activate the next job if it's finished, and return the active job
If the current job has failed, a NutchCrawlException will be raised with no jobs attached.
:param nextRound: whether to start jobs from the next round if the current job/round is completed.
:... |
Execute all jobs in the current round and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs from this round attached
to the exception.
:return: a list of all completed Jobs
def nextRound(self):
"""
Execute all jobs in... |
Execute all queued rounds and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs attached
to the exception
:return: a list of jobs completed for each round, organized by round (list-of-lists)
def waitAll(self):
"""
Exe... |
Create a JobClient for listing and creating jobs.
The JobClient inherits the confId from the Nutch client.
:param crawlId: crawlIds to use for this client. If not provided, will be generated
by nutch.defaultCrawlId()
:return: a JobClient
def Jobs(self, crawlId=None):
"""
... |
Launch a crawl using the given seed
:param seed: Type (Seed or SeedList) - used for crawl
:param seedClient: if a SeedList is given, the SeedClient to upload, if None a default will be created
:param jobClient: the JobClient to be used, if None a default will be created
:param rounds: th... |
>>> import pprint
>>> input_line1 = 'Apr 24 00:00:02 node haproxy[12298]: 1.1.1.1:48660 [24/Apr/2019:00:00:02.358] pre-staging~ pre-staging_doc/pre-staging_active 261/0/2/8/271 200 2406 - - ---- 4/4/0/1/0 0/0 {AAAAAA:AAAAA_AAAAA:AAAAA_AAAAA_AAAAA:300A||| user@mail.net:sdasdasdasdsdasAHDivsjd=|user@mail.net|2018} "G... |
>>> import pprint
>>> input_line1 = '{ \
"remote_addr": "127.0.0.1","remote_user": "-","timestamp": "1515144699.201", \
"request": "GET / HTTP/1.1","status": "200","request_time": "0.000", \
"body_bytes_sent": "396","http_referer": "-","http_user_agent": "... |
>>> import pprint
>>> input_line1 = '2017-08-17T07:56:33.489+0200 I REPL [signalProcessingThread] shutting down replication subsystems'
>>> output_line1 = mongodb(input_line1)
>>> pprint.pprint(output_line1)
{'data': {'component': 'REPL',
'context': '[signalProcessingThread]',
... |
>>> import pprint
>>> input_line1 = '[23/Aug/2017 11:35:25] INFO [app.middleware_log_req:50]View func called:{"exception": null,"processing_time": 0.00011801719665527344, "url": "<url>",host": "localhost", "user": "testing", "post_contents": "", "method": "POST" }'
>>> output_line1 = django(input_line1)
>>>... |
>>> import pprint
>>> input_line = '{"level": "warning", "timestamp": "2018-02-07T06:37:00.297610Z", "event": "exited via keyboard interrupt", "type": "log", "id": "20180207T063700_4d03fe800bd111e89ecb96000007bc65", "_": {"ln": 58, "file": "/usr/local/lib/python2.7/dist-packages/basescript/basescript.py", "name": "... |
>>> import pprint
>>> input_line = '[2017-08-30T06:27:19,158] [WARN ][o.e.m.j.JvmGcMonitorService] [Glsuj_2] [gc][296816] overhead, spent [1.2s] collecting in the last [1.3s]'
>>> output_line = elasticsearch(input_line)
>>> pprint.pprint(output_line)
{'data': {'garbage_collector': 'gc',
'g... |
>>> line1 = ' [2018-04-03T00:22:38,048][DEBUG][o.e.c.u.c.QueueResizingEsThreadPoolExecutor] [search17/search]: there were [2000] tasks in [809ms], avg task time [28.4micros], EWMA task execution [790nanos], [35165.36 tasks/s], optimal queue is [35165], current capacity [1000]'
>>> line2 = ' org.elasticsearch.Reso... |
Get an attribute defined by this session
def get(self, attr, default=None):
"""Get an attribute defined by this session"""
attrs = self.body.get('attributes') or {}
return attrs.get(attr, default) |
if data can't found in cache then it will be fetched from db,
parsed and stored to cache for each lang_code.
:param cat: cat of catalog data
:return:
def get_all(self, cat):
"""
if data can't found in cache then it will be fetched from db,
parsed and stored to cache f... |
get from redis, cache locally then return
:param catalog: catalog name
:param key:
:return:
def _fill_get_item_cache(self, catalog, key):
"""
get from redis, cache locally then return
:param catalog: catalog name
:param key:
:return:
"""
... |
Utility method to quickly get a server up and running.
:param debug: turns on Werkzeug debugger, code reloading, and full
logging.
:param validate_requests: whether or not to ensure that requests are
sent by Amazon. This can be usefulfor manually testing the server.
def run(sel... |
Given a parsed JSON request object, call the correct Intent, Launch,
or SessionEnded function.
This function is called after request parsing and validaion and will
raise a `ValueError` if an unknown request type comes in.
:param body: JSON object loaded from incoming request's POST dat... |
Decorator to register a handler for the given intent.
The decorated function can either take 0 or 2 arguments. If two are
specified, it will be provided a dictionary of `{slot_name: value}` and
a :py:class:`alexandra.session.Session` instance.
If no session was provided in the request,... |
Kullanıcı şifresini encrypt ederek set eder.
Args:
raw_password (str)
def set_password(self, raw_password):
"""
Kullanıcı şifresini encrypt ederek set eder.
Args:
raw_password (str)
"""
self.password = pbkdf2_sha512.encrypt(raw_password, rounds=... |
encrypt password if not already encrypted
def encrypt_password(self):
""" encrypt password if not already encrypted """
if self.password and not self.password.startswith('$pbkdf2'):
self.set_password(self.password) |
sends message to users private mq exchange
Args:
title:
message:
sender:
url:
typ:
def send_notification(self, title, message, typ=1, url=None, sender=None):
"""
sends message to users private mq exchange
Args:
titl... |
Send arbitrary cmd and data to client
if queue name passed by "via_queue" parameter,
that queue will be used instead of users private exchange.
Args:
data: dict
cmd: string
via_queue: queue name,
def send_client_cmd(self, data, cmd=None, via_queue=None):
... |
shifts on a given number of record in the original file
:param offset: number of record
def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts)... |
:return: number of records processed from the original file
def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
if t == self._shifts[0]:
return 0
elif t == self._sh... |
Assigning the workflow to itself.
The selected job is checked to see if there is an assigned role.
If it does not have a role assigned to it, it takes the job to itself
and displays a message that the process is successful.
If there is a role assigned to it, it does not d... |
The workflow method to be assigned to the person with the same role and unit as the user.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
def select_role(self):
"""
The workflow method to be assigned to... |
With the workflow instance and the task invitation is assigned a role.
def send_workflow(self):
"""
With the workflow instance and the task invitation is assigned a role.
"""
task_invitation = TaskInvitation.objects.get(self.task_invitation_key)
wfi = task_invitation.instance
... |
The time intervals at which the workflow is to be extended are determined.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
def select_postponed_date(self):
"""
The time intervals at which the workfl... |
Invitations with the same workflow status are deleted.
Workflow instance and invitation roles change.
def save_date(self):
"""
Invitations with the same workflow status are deleted.
Workflow instance and invitation roles change.
"""
task_invitation = TaskInv... |
If there is a role assigned to the workflow and
it is the same as the user, it can drop the workflow.
If it does not exist, it can not do anything.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
def s... |
Finds out if the piece is on the home row.
:return: bool for whether piece is on home row or not
def on_home_row(self, location=None):
"""
Finds out if the piece is on the home row.
:return: bool for whether piece is on home row or not
"""
location = location or self.l... |
Finds if move from current get_location would result in promotion
:type: location: Location
:rtype: bool
def would_move_be_promotion(self, location=None):
"""
Finds if move from current get_location would result in promotion
:type: location: Location
:rtype: bool
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.