Package qubx :: Module pyenv
[hide private]
[frames] | no frames]

Module pyenv

source code

Support for user scripting, including

The official global scope is module qubx.global_namespace, populated from global_names.py to avoid circular imports

The exec_* environments eat exceptions and report them via env.On*Exception callbacks (except exec_file with default raise_exceptions=True).

Copyright 2007-2014 Research Foundation State University of New York This file is part of QUB Express.

QUB Express is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QUB Express is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License, named LICENSE.txt, in the QUB Express program directory. If not, see <http://www.gnu.org/licenses/>.

Classes [hide private]
  PythonEnvironment
Python environment management for user scripting.
  PluginManager
  DeferredAction
Calls a func(*args, **kw) after a short delay; if multiple expressions are received from one source within the delay time, only the final one is passed through; if the source changes, previous func is called immediately.
  DeferredScriptable
Passes through expressions to qubx.pyenv.env.OnScriptable after a short delay; if multiple expressions are received from one source within the delay time, only the final one is passed through.
  DeferredScriptableScroll
  ScriptRecursionError
  ScriptModule
  DeferredSideEffects
Context manager, for use in a script, which disables the trace function -- faster execution because it doesn't wait for side-effects to complete after each line -- but dangerous if the side effects need to happen before the script continues.
Functions [hide private]
 
call_now(func, *args, **kw) source code
 
call_no_delay(ms, func, *args, **kw) source code
 
bind_scriptable_base(bind_f, expr, callback, *args, **kw) source code
 
bind_scriptable(expr, callback, *args, **kw)
Wrapper for qubx.util_types.bind which emits pyenv.OnScriptable(expr) prior to each callback.
source code
 
bind_with_args_scriptable(expr, callback, *args, **kw)
Wrapper for qubx.util_types.bind which emits pyenv.OnScriptable(expr) prior to each callback.
source code
 
bind_with_args_before_scriptable(expr, callback, *args, **kw)
Wrapper for qubx.util_types.bind which emits pyenv.OnScriptable(expr) prior to each callback.
source code
 
parse_version_str(vs) source code
 
read_version(text, symbol='VERSION') source code
 
read_plugin_version(path) source code
 
plugin_version_cmp(v1, v2)
Returns -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2.
source code
 
sort_alphabetical(lst) source code
 
call_async_wait(func, *args, **kw)
Calls func, returns a delayed result via call_later
source code
 
doze(seconds)
Runs a recursive main loop for a number of seconds, then returns.
source code
 
featured_property_name(cls) source code
 
generate_featured(cls, obj=None, recursive=True) source code
 
has_featured_impl(cls) source code
 
get_name_map_featured(obj, objname='') source code
 
is_functional_class(class_str) source code
 
mark_instances(in_modules=[<module 'qubx' from '/j/svn/qub-express/qubx/__init__.pyc'>], max_depth=7)
To help bridge the gap between the class hierarchy and the working global namespace, creates a defaultdict(list) INSTANCES in each sub-module of the listed modules, with global names of instances.
source code
 
format_classname(cls) source code
 
Init(folder, call_later=<__builtin__.function object>, call_delayed=<__builtin__.function object>, MainLoop=None, process_events=<__builtin__.function object>, app_path=None)
Sets up the global variable "env" (class PythonEnvironment)
source code
Variables [hide private]
  env = None
hash(x)
  featured_pat = re.compile(r'\.([^\.\']+)\'')
  functional_class_str = set(['<type \'builtin_function_or_metho...
  classname_pat = re.compile(r'.*\.([^\.\']+)\'')
  PYTHON_HELP = '\nbasic operators: +, -, *, /\nexponents: pow(b...
  __package__ = 'qubx'
Function Details [hide private]

call_async_wait(func, *args, **kw)

source code 
Calls func, returns a delayed result via call_later

func must be written to return a result via a callback on the main event loop, e.g.
    >>> gobject.idle_add(receiver, results, ...)
It will be called
    >>> func(receiver, *args, **kw)
then a recursive main loop will run until receiver is called (be careful this is not forever).
Receiver's args are returned as a tuple.

mark_instances(in_modules=[<module 'qubx' from '/j/svn/qub-express/qubx/__init__.pyc'>], max_depth=7)

source code 

To help bridge the gap between the class hierarchy and the working global namespace, creates a defaultdict(list) INSTANCES in each sub-module of the listed modules, with global names of instances.

Parameters:
  • module - e.g. qubx
  • max_depth - how many dots (or dict/list lookups) to descend through the global hierarchy

Init(folder, call_later=<__builtin__.function object>, call_delayed=<__builtin__.function object>, MainLoop=None, process_events=<__builtin__.function object>, app_path=None)

source code 

Sets up the global variable "env" (class PythonEnvironment)

Parameters:
  • folder - path where settings and logs are saved
  • call_later - e.g. gobject.idle_add if your OnOutput callback calls on gtk
  • call_delayed - e.g. gobject.timeout_add if your OnOutput callback calls on gtk
  • MainLoop - e.g. gobject.MainLoop or act-alike; req. for call_async_wait and doze only
  • process_events - func() which processes any outstanding events before returning
  • app_path - location of global_names.py

Variables Details [hide private]

functional_class_str

Value:
set(['<type \'builtin_function_or_method\'>',
     '<type \'function\'>',
     '<type \'instancemethod\'>',
     '<type \'numpy.ufunc\'>'])

PYTHON_HELP

Value:
'''
basic operators: +, -, *, /
exponents: pow(base, exp) or base**exp

standard math: pow, exp, log, log10, ceil, floor, fabs, cos, sin, tan,\
 acos, asin, atan, atan2, ...
Type e.g. "help(atan2)" at the ">>>" prompt for details.

...