Search is not available for this dataset
text stringlengths 75 104k |
|---|
def set_manage_params(
self, chunked_input=None, chunked_output=None, gzip=None, websockets=None, source_method=None,
rtsp=None, proxy_protocol=None):
"""Allows enabling various automatic management mechanics.
* http://uwsgi.readthedocs.io/en/latest/Changelog-1.9.html#http-route... |
def set_owner_params(self, uid=None, gid=None):
"""Drop http router privileges to specified user and group.
:param str|unicode|int uid: Set uid to the specified username or uid.
:param str|unicode|int gid: Set gid to the specified groupname or gid.
"""
self._set_aliased('uid',... |
def set_connections_params(self, harakiri=None, timeout_socket=None, retry_delay=None, retry_max=None):
"""Sets connection-related parameters.
:param int harakiri: Set gateway harakiri timeout (seconds).
:param int timeout_socket: Node socket timeout (seconds). Default: 60.
:param int... |
def set_basic_params(
self, workers=None, zerg_server=None, fallback_node=None, concurrent_events=None,
cheap_mode=None, stats_server=None, quiet=None, buffer_size=None,
fallback_nokey=None, subscription_key=None, emperor_command_socket=None):
"""
:param int workers: ... |
def set_resubscription_params(self, addresses=None, bind_to=None):
"""You can specify a dgram address (udp or unix) on which all of the subscriptions
request will be forwarded to (obviously changing the node address to the router one).
The system could be useful to build 'federated' setup.
... |
def set_connections_params(self, harakiri=None, timeout_socket=None, retry_delay=None, retry_max=None, defer=None):
"""Sets connection-related parameters.
:param int harakiri: Set gateway harakiri timeout (seconds).
:param int timeout_socket: Node socket timeout (seconds). Default: 60.
... |
def set_postbuffering_params(self, size=None, store_dir=None):
"""Sets buffering params.
Web-proxies like nginx are "buffered", so they wait til the whole request (and its body)
has been read, and then it sends it to the backends.
:param int size: The size (in bytes) of the request bod... |
def set_connections_params(
self, harakiri=None, timeout_socket=None, retry_delay=None, retry_max=None, use_xclient=None):
"""Sets connection-related parameters.
:param int harakiri: Set gateway harakiri timeout (seconds).
:param int timeout_socket: Node socket timeout (seconds). ... |
def set_connections_params(self, harakiri=None, timeout_socket=None):
"""Sets connection-related parameters.
:param int harakiri: Set gateway harakiri timeout (seconds).
:param int timeout_socket: Node socket timeout (seconds). Default: 60.
"""
self._set_aliased('harakiri', ha... |
def set_window_params(self, cols=None, rows=None):
"""Sets pty window params.
:param int cols:
:param int rows:
"""
self._set_aliased('cols', cols)
self._set_aliased('rows', rows)
return self |
def set_basic_params(self, use_credentials=None, stats_server=None):
"""
:param str|unicode use_credentials: Enable check of SCM_CREDENTIALS for tuntap client/server.
:param str|unicode stats_server: Router stats server address to run at.
"""
self._set_aliased('use-credentials'... |
def register_route(self, src, dst, gateway):
"""Adds a routing rule to the tuntap router.
:param str|unicode src: Source/mask.
:param str|unicode dst: Destination/mask.
:param str|unicode gateway: Gateway address.
"""
self._set_aliased('router-route', ' '.join((src, d... |
def device_add_rule(self, direction, action, src, dst, target=None):
"""Adds a tuntap device rule.
To be used in a vassal.
:param str|unicode direction: Direction:
* in
* out.
:param str|unicode action: Action:
* allow
* deny
... |
def add_firewall_rule(self, direction, action, src=None, dst=None):
"""Adds a firewall rule to the router.
The TunTap router includes a very simple firewall for governing vassal's traffic.
The first matching rule stops the chain, if no rule applies, the policy is "allow".
:param str|un... |
def configure_uwsgi(configurator_func):
"""Allows configuring uWSGI using Configuration objects returned
by the given configuration function.
.. code-block: python
# In configuration module, e.g `uwsgicfg.py`
from uwsgiconf.config import configure_uwsgi
configure_uwsgi(get_config... |
def replace_placeholders(self, value):
"""Replaces placeholders that can be used e.g. in filepaths.
Supported placeholders:
* {project_runtime_dir}
* {project_name}
* {runtime_dir}
:param str|unicode|list[str|unicode]|None value:
:rtype: None|str|uni... |
def get_runtime_dir(self, default=True):
"""Directory to store runtime files.
See ``.replace_placeholders()``
.. note:: This can be used to store PID files, sockets, master FIFO, etc.
:param bool default: Whether to return [system] default if not set.
:rtype: str|unicode
... |
def print_stamp(self):
"""Prints out a stamp containing useful information,
such as what and when has generated this configuration.
"""
from . import VERSION
print_out = partial(self.print_out, format_options='red')
print_out('This configuration was automatically genera... |
def print_out(self, value, indent=None, format_options=None, asap=False):
"""Prints out the given value.
:param value:
:param str|unicode indent:
:param dict|str|unicode format_options: text color
:param bool asap: Print as soon as possible.
"""
if indent is ... |
def print_variables(self):
"""Prints out magic variables available in config files
alongside with their values and descriptions.
May be useful for debugging.
http://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#magic-variables
"""
print_out = partial(self.print... |
def set_plugins_params(self, plugins=None, search_dirs=None, autoload=None, required=False):
"""Sets plugin-related parameters.
:param list|str|unicode|OptionsGroup|list[OptionsGroup] plugins: uWSGI plugins to load
:param list|str|unicode search_dirs: Directories to search for uWSGI plugins.
... |
def set_fallback(self, target):
"""Sets a fallback configuration for section.
Re-exec uWSGI with the specified config when exit code is 1.
:param str|unicode|Section target: File path or Section to include.
"""
if isinstance(target, Section):
target = ':' + target.n... |
def set_placeholder(self, key, value):
"""Placeholders are custom magic variables defined during configuration
time.
.. note:: These are accessible, like any uWSGI option, in your application code via
``.runtime.environ.uwsgi_env.config``.
:param str|unicode key:
:... |
def env(self, key, value=None, unset=False, asap=False):
"""Processes (sets/unsets) environment variable.
If is not given in `set` mode value will be taken from current env.
:param str|unicode key:
:param value:
:param bool unset: Whether to unset this variable.
:par... |
def include(self, target):
"""Includes target contents into config.
:param str|unicode|Section|list target: File path or Section to include.
"""
for target_ in listify(target):
if isinstance(target_, Section):
target_ = ':' + target_.name
self._s... |
def derive_from(cls, section, name=None):
"""Creates a new section based on the given.
:param Section section: Section to derive from,
:param str|unicode name: New section name.
:rtype: Section
"""
new_section = deepcopy(section)
if name:
new_secti... |
def _validate_sections(cls, sections):
"""Validates sections types and uniqueness."""
names = []
for section in sections:
if not hasattr(section, 'name'):
raise ConfigurationError('`sections` attribute requires a list of Section')
name = section.name
... |
def format(self, do_print=False, stamp=True):
"""Applies formatting to configuration.
*Currently formats to .ini*
:param bool do_print: Whether to print out formatted config.
:param bool stamp: Whether to add stamp data to the first configuration section.
:rtype: str|unicode
... |
def tofile(self, filepath=None):
"""Saves configuration into a file and returns its path.
Convenience method.
:param str|unicode filepath: Filepath to save configuration into.
If not provided a temporary file will be automatically generated.
:rtype: str|unicode
""... |
def _set_name(self, version=AUTO):
"""Returns plugin name."""
name = 'python'
if version:
if version is AUTO:
version = sys.version_info[0]
if version == 2:
version = ''
name = '%s%s' % (name, version)
self.... |
def set_app_args(self, *args):
"""Sets ``sys.argv`` for python apps.
Examples:
* pyargv="one two three" will set ``sys.argv`` to ``('one', 'two', 'three')``.
:param args:
"""
if args:
self._set('pyargv', ' '.join(args))
return self._section |
def set_wsgi_params(self, module=None, callable_name=None, env_strategy=None):
"""Set wsgi related parameters.
:param str|unicode module:
* load .wsgi file as the Python application
* load a WSGI module as the application.
.. note:: The module (sans ``.py``) must be... |
def set_autoreload_params(self, scan_interval=None, ignore_modules=None):
"""Sets autoreload related parameters.
:param int scan_interval: Seconds. Monitor Python modules' modification times to trigger reload.
.. warning:: Use only in development.
:param list|st|unicode ignore_mod... |
def register_module_alias(self, alias, module_path, after_init=False):
"""Adds an alias for a module.
http://uwsgi-docs.readthedocs.io/en/latest/PythonModuleAlias.html
:param str|unicode alias:
:param str|unicode module_path:
:param bool after_init: add a python module alias af... |
def import_module(self, modules, shared=False, into_spooler=False):
"""Imports a python module.
:param list|str|unicode modules:
:param bool shared: Import a python module in all of the processes.
This is done after fork but before request processing.
:param bool into_spoo... |
def set_server_params(
self, client_notify_address=None, mountpoints_depth=None, require_vassal=None,
tolerance=None, tolerance_inactive=None, key_dot_split=None):
"""Sets subscription server related params.
:param str|unicode client_notify_address: Set the notification socket f... |
def set_server_verification_params(
self, digest_algo=None, dir_cert=None, tolerance=None, no_check_uid=None,
dir_credentials=None, pass_unix_credentials=None):
"""Sets peer verification params for subscription server.
These are for secured subscriptions.
:param str|uni... |
def set_client_params(
self, start_unsubscribed=None, clear_on_exit=None, unsubscribe_on_reload=None,
announce_interval=None):
"""Sets subscribers related params.
:param bool start_unsubscribed: Configure subscriptions but do not send them.
.. note:: Useful with mast... |
def subscribe(
self, server=None, key=None, address=None, address_vassal=None,
balancing_weight=None, balancing_algo=None, modifier=None, signing=None, check_file=None, protocol=None,
sni_cert=None, sni_key=None, sni_client_ca=None):
"""Registers a subscription intent.
... |
def find_project_dir():
"""Runs up the stack to find the location of manage.py
which will be considered a project base path.
:rtype: str|unicode
"""
frame = inspect.currentframe()
while True:
frame = frame.f_back
fname = frame.f_globals['__file__']
if os.path.basename(... |
def run_uwsgi(config_section, compile_only=False):
"""Runs uWSGI using the given section configuration.
:param Section config_section:
:param bool compile_only: Do not run, only compile and output configuration file for run.
"""
config = config_section.as_configuration()
if compile_only:
... |
def spawn(cls, options=None, dir_base=None):
"""Alternative constructor. Creates a mutator and returns section object.
:param dict options:
:param str|unicode dir_base:
:rtype: SectionMutator
"""
from uwsgiconf.utils import ConfModule
options = options or {
... |
def _get_section_existing(self, name_module, name_project):
"""Loads config section from existing configuration file (aka uwsgicfg.py)
:param str|unicode name_module:
:param str|unicode name_project:
:rtype: Section
"""
from importlib import import_module
from ... |
def _get_section_new(cls, dir_base):
"""Creates a new section with default settings.
:param str|unicode dir_base:
:rtype: Section
"""
from uwsgiconf.presets.nice import PythonSection
from django.conf import settings
wsgi_app = settings.WSGI_APPLICATION
... |
def contribute_static(self):
"""Contributes static and media file serving settings to an existing section."""
options = self.options
if options['compile'] or not options['use_static_handler']:
return
from django.core.management import call_command
settings = self.s... |
def contribute_error_pages(self):
"""Contributes generic static error massage pages to an existing section."""
static_dir = self.settings.STATIC_ROOT
if not static_dir:
# Source static directory is not configured. Use temporary.
import tempfile
static_dir = ... |
def mutate(self):
"""Mutates current section."""
section = self.section
project_name = self.project_name
section.project_name = project_name
self.contribute_runtime_dir()
main = section.main_process
main.set_naming_params(prefix='[%s] ' % project_name)
... |
def register_file_monitor(filename, target=None):
"""Maps a specific file/directory modification event to a signal.
:param str|unicode filename: File or a directory to watch for its modification.
:param int|Signal|str|unicode target: Existing signal to raise
or Signal Target to register signal imp... |
def set(self, value, mode=None):
"""Sets metric value.
:param int|long value: New value.
:param str|unicode mode: Update mode.
* None - Unconditional update.
* max - Sets metric value if it is greater that the current one.
* min - Sets metric value if it is... |
def get_message(cls, signals=True, farms=False, buffer_size=65536, timeout=-1):
"""Block until a mule message is received and return it.
This can be called from multiple threads in the same programmed mule.
:param bool signals: Whether to manage signals.
:param bool farms: Whether to ... |
def regenerate(session):
"""Regenerates header files for cmark under ./generated."""
if platform.system() == 'Windows':
output_dir = '../generated/windows'
else:
output_dir = '../generated/unix'
session.run(shutil.rmtree, 'build', ignore_errors=True)
session.run(os.makedirs,... |
def output_capturing():
"""Temporarily captures/redirects stdout."""
out = sys.stdout
sys.stdout = StringIO()
try:
yield
finally:
sys.stdout = out |
def filter_locals(locals_dict, drop=None, include=None):
"""Filters a dictionary produced by locals().
:param dict locals_dict:
:param list drop: Keys to drop from dict.
:param list include: Keys to include into dict.
:rtype: dict
"""
drop = drop or []
drop.extend([
'self',
... |
def get_output(cmd, args):
"""Runs a command and returns its output (stdout + stderr).
:param str|unicode cmd:
:param str|unicode|list[str|unicode] args:
:rtype: str|unicode
"""
from subprocess import Popen, STDOUT, PIPE
command = [cmd]
command.extend(listify(args))
process = Po... |
def parse_command_plugins_output(out):
"""Parses ``plugin-list`` command output from uWSGI
and returns object containing lists of embedded plugin names.
:param str|unicode out:
:rtype EmbeddedPlugins:
"""
out = out.split('--- end of plugins list ---')[0]
out = out.partition('plugins ***')... |
def get_uwsgi_stub_attrs_diff():
"""Returns attributes difference two elements tuple between
real uwsgi module and its stub.
Might be of use while describing in stub new uwsgi functions.
:return: (uwsgi_only_attrs, stub_only_attrs)
:rtype: tuple
"""
try:
import uwsgi
except ... |
def spawn_uwsgi(self, only=None):
"""Spawns uWSGI process(es) which will use configuration(s) from the module.
Returns list of tuples:
(configuration_alias, uwsgi_process_id)
If only one configuration found current process (uwsgiconf) is replaced with a new one (uWSGI),
oth... |
def configurations(self):
"""Configurations from uwsgiconf module."""
if self._confs is not None:
return self._confs
with output_capturing():
module = self.load(self.fpath)
confs = getattr(module, CONFIGS_MODULE_ATTR)
confs = listify(confs)
... |
def load(cls, fpath):
"""Loads a module and returns its object.
:param str|unicode fpath:
:rtype: module
"""
module_name = os.path.splitext(os.path.basename(fpath))[0]
sys.path.insert(0, os.path.dirname(fpath))
try:
module = import_module(module_name... |
def cmd_log(self, reopen=False, rotate=False):
"""Allows managing of uWSGI log related stuff
:param bool reopen: Reopen log file. Could be required after third party rotation.
:param bool rotate: Trigger built-in log rotation.
"""
cmd = b''
if reopen:
cmd +... |
def cmd_reload(self, force=False, workers_only=False, workers_chain=False):
"""Reloads uWSGI master process, workers.
:param bool force: Use forced (brutal) reload instead of a graceful one.
:param bool workers_only: Reload only workers.
:param bool workers_chain: Run chained workers re... |
def send_command(self, cmd):
"""Sends a generic command into FIFO.
:param bytes cmd: Command chars to send into FIFO.
"""
if not cmd:
return
with open(self.fifo, 'wb') as f:
f.write(cmd) |
def get_env_path(cls):
"""Returns PATH environment variable updated to run uwsgiconf in
(e.g. for virtualenv).
:rtype: str|unicode
"""
return os.path.dirname(Finder.python()) + os.pathsep + os.environ['PATH'] |
def prepare_env(cls):
"""Prepares current environment and returns Python binary name.
This adds some virtualenv friendliness so that we try use uwsgi from it.
:rtype: str|unicode
"""
os.environ['PATH'] = cls.get_env_path()
return os.path.basename(Finder.python()) |
def spawn(self, filepath, configuration_alias, replace=False):
"""Spawns uWSGI using the given configuration module.
:param str|unicode filepath:
:param str|unicode configuration_alias:
:param bool replace: Whether a new process should replace current one.
"""
# Pass ... |
def get(self, key, default=None, as_int=False, setter=None):
"""Gets a value from the cache.
:param str|unicode key: The cache key to get value for.
:param default: Value to return if none found in cache.
:param bool as_int: Return 64bit number instead of str.
:param callable... |
def set(self, key, value):
"""Sets the specified key value.
:param str|unicode key:
:param int|str|unicode value:
:rtype: bool
"""
return uwsgi.cache_set(key, value, self.timeout, self.name) |
def incr(self, key, delta=1):
"""Increments the specified key value by the specified value.
:param str|unicode key:
:param int delta:
:rtype: bool
"""
return uwsgi.cache_inc(key, delta, self.timeout, self.name) |
def decr(self, key, delta=1):
"""Decrements the specified key value by the specified value.
:param str|unicode key:
:param int delta:
:rtype: bool
"""
return uwsgi.cache_dec(key, delta, self.timeout, self.name) |
def mul(self, key, value=2):
"""Multiplies the specified key value by the specified value.
:param str|unicode key:
:param int value:
:rtype: bool
"""
return uwsgi.cache_mul(key, value, self.timeout, self.name) |
def div(self, key, value=2):
"""Divides the specified key value by the specified value.
:param str|unicode key:
:param int value:
:rtype: bool
"""
return uwsgi.cache_mul(key, value, self.timeout, self.name) |
def recv(request_context=None, non_blocking=False):
"""Receives data from websocket.
:param request_context:
:param bool non_blocking:
:rtype: bytes|str
:raises IOError: If unable to receive a message.
"""
if non_blocking:
result = uwsgi.websocket_recv_nb(request_context)
e... |
def send(message, request_context=None, binary=False):
"""Sends a message to websocket.
:param str message: data to send
:param request_context:
:raises IOError: If unable to send a message.
"""
if binary:
return uwsgi.websocket_send_binary(message, request_context)
return uwsgi.... |
def markdown_to_html(text, options=0):
"""Render the given text to Markdown.
This is a direct interface to ``cmark_markdown_to_html``.
Args:
text (str): The text to render to Markdown.
options (int): The cmark options.
Returns:
str: The rendered markdown.
"""
... |
def markdown_to_html_with_extensions(text, options=0, extensions=None):
"""Render the given text to Markdown, using extensions.
This is a high-level wrapper over the various functions needed to enable
extensions, attach them to a parser, and render html.
Args:
text (str): The text to re... |
def parse_document(text, options=0):
"""Parse a document and return the root node.
Args:
text (str): The text to parse.
options (int): The cmark options.
Returns:
Any: Opaque reference to the root node of the parsed syntax tree.
"""
encoded_text = text.encode('utf... |
def parser_feed(parser, text):
"""Direct wrapper over cmark_parser_feed."""
encoded_text = text.encode('utf-8')
return _cmark.lib.cmark_parser_feed(
parser, encoded_text, len(encoded_text)) |
def render_html(root, options=0, extensions=None):
"""Render a given syntax tree as HTML.
Args:
root (Any): The reference to the root node of the syntax tree.
options (int): The cmark options.
extensions (Any): The reference to the syntax extensions, generally
from :f... |
def find_syntax_extension(name):
"""Direct wrapper over cmark_find_syntax_extension."""
encoded_name = name.encode('utf-8')
extension = _cmark.lib.cmark_find_syntax_extension(encoded_name)
if extension == _cmark.ffi.NULL:
return None
else:
return extension |
def set_basic_params(self, no_expire=None, expire_scan_interval=None, report_freed=None):
"""
:param bool no_expire: Disable auto sweep of expired items.
Since uWSGI 1.2, cache item expiration is managed by a thread in the master process,
to reduce the risk of deadlock. This thre... |
def add_item(self, key, value, cache_name=None):
"""Add an item into the given cache.
This is a commodity option (mainly useful for testing) allowing you
to store an item in a uWSGI cache during startup.
:param str|unicode key:
:param value:
:param str|unicode cache_n... |
def add_file(self, filepath, gzip=False, cache_name=None):
"""Load a static file in the cache.
.. note:: Items are stored with the filepath as is (relative or absolute) as the key.
:param str|unicode filepath:
:param bool gzip: Use gzip compression.
:param str|unicode cache_n... |
def add_cache(
self, name, max_items, expires=None, store=None, store_sync_interval=None, store_delete=None,
hash_algo=None, hash_size=None, key_size=None, udp_clients=None, udp_servers=None,
block_size=None, block_count=None, sync_from=None, mode_bitmap=None, use_lastmod=None,
... |
def register_timer(period, target=None):
"""Add timer.
Can be used as a decorator:
.. code-block:: python
@register_timer(3)
def repeat():
do()
:param int period: The interval (seconds) at which to raise the signal.
:param int|Signal|str|unicode targe... |
def register_timer_rb(period, repeat=None, target=None):
"""Add a red-black timer (based on black-red tree).
.. code-block:: python
@register_timer_rb(3)
def repeat():
do()
:param int period: The interval (seconds) at which the signal is raised.
:param int... |
def register_cron(weekday=None, month=None, day=None, hour=None, minute=None, target=None):
"""Adds cron. The interface to the uWSGI signal cron facility.
.. code-block:: python
@register_cron(hour=-3) # Every 3 hours.
def repeat():
do()
.. note:: Arguments wo... |
def truncate_ellipsis(line, length=30):
"""Truncate a line to the specified length followed by ``...`` unless its shorter than length already."""
l = len(line)
return line if l < length else line[:length - 3] + "..." |
def pyle_evaluate(expressions=None, modules=(), inplace=False, files=None, print_traceback=False):
"""The main method of pyle."""
eval_globals = {}
eval_globals.update(STANDARD_MODULES)
for module_arg in modules or ():
for module in module_arg.strip().split(","):
module = module.s... |
def pyle(argv=None):
"""Execute pyle with the specified arguments, or sys.argv if no arguments specified."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-m", "--modules", dest="modules", action='append',
help="import MODULE before evaluation. May be specified more th... |
def convert_to_international_phonetic_alphabet(self, arpabet):
'''
转换成国际音标
:param arpabet:
:return:
'''
word = self._convert_to_word(arpabet=arpabet)
if not word:
return None
return word.translate_to_international_phonetic_alphabet() |
def convert_to_american_phonetic_alphabet(self, arpabet):
'''
转换成美音
:param arpabet:
:return:
'''
word = self._convert_to_word(arpabet=arpabet)
if not word:
return None
return word.translate_to_american_phonetic_alphabet() |
def convert_to_english_phonetic_alphabet(self, arpabet):
'''
转换成英音
:param arpabet:
:return:
'''
word = self._convert_to_word(arpabet=arpabet)
if not word:
return None
return word.translate_to_english_phonetic_alphabet() |
def translate_to_arpabet(self):
'''
转换成arpabet
:return:
'''
translations = []
for phoneme in self._phoneme_list:
if phoneme.is_vowel:
translations.append(phoneme.arpabet + self.stress.mark_arpabet())
else:
translat... |
def translate_to_american_phonetic_alphabet(self, hide_stress_mark=False):
'''
转换成美音音。只要一个元音的时候需要隐藏重音标识
:param hide_stress_mark:
:return:
'''
translations = self.stress.mark_ipa() if (not hide_stress_mark) and self.have_vowel else ""
for phoneme in self._phonem... |
def translate_to_english_phonetic_alphabet(self, hide_stress_mark=False):
'''
转换成英音。只要一个元音的时候需要隐藏重音标识
:param hide_stress_mark:
:return:
'''
translations = self.stress.mark_ipa() if (not hide_stress_mark) and self.have_vowel else ""
for phoneme in self._phoneme_l... |
def translate_to_international_phonetic_alphabet(self, hide_stress_mark=False):
'''
转换成国际音标。只要一个元音的时候需要隐藏重音标识
:param hide_stress_mark:
:return:
'''
translations = self.stress.mark_ipa() if (not hide_stress_mark) and self.have_vowel else ""
for phoneme in self._p... |
def get_login_form_component(self):
"""Initializes and returns the login form component
@rtype: LoginForm
@return: Initialized component
"""
self.dw.wait_until(
lambda: self.dw.is_present(LoginForm.locators.form),
failure_message='login form was never pre... |
def objectify(dictionary, name='Object'):
"""Converts a dictionary into a named tuple (shallow)
"""
o = namedtuple(name, dictionary.keys())(*dictionary.values())
return o |
def create_directory(directory):
"""Creates a directory if it does not exist (in a thread-safe way)
@param directory: The directory to create
@return: The directory specified
"""
try:
os.makedirs(directory)
except OSError, e:
if e.errno == errno.EEXIST and os.path.isdir(director... |
def __add_query_comment(sql):
"""
Adds a comment line to the query to be executed containing the line number of the calling
function. This is useful for debugging slow queries, as the comment will show in the slow
query log
@type sql: str
@param sql: sql needing comment... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.