-
Notifications
You must be signed in to change notification settings - Fork 218
sitecustomize.py
hashstat edited this page May 26, 2015
·
1 revision
# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
# GPLv2 or later
# Version: 20081123
# Features:
# * set proper default encoding
# * enable readline completion in the interactive interpreter
# * load command line history on startup
# * save command line history on exit
'''Use readline to make the interactive interpreter more friendly.
The readline module should only be imported in interactive mode because
it has side-effects which may interfere with the output of scripts. But
because sitecustomize is executed at such an early stage of Python
initialization it cannot determine if Python is executed interactively.
Therefore, this script injects itself as the PYTHONSETUP script where
interactivity can be determined. The PYTHONSETUP environment is first
saved in the environment so it can later be restored. Then, PYTHONSETUP
is set to this script. After executing this script as the PYTHONSETUP
script, the original PYTHONSETUP, script is restored and, if set, is
exectuted.
'''
def main():
'''This function wraps up the script to keep the environment clean.'''
import os
def __exithandler():
try:
readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
except IOError:
pass
def __registerExitHandler():
import atexit
atexit.register( __exithandler )
def __enableReadlineSupport():
readline.set_history_length( 1000 )
readline.parse_and_bind( "tab: complete" )
try:
readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
except IOError:
pass
def __enableDefaultEncoding():
import sys
try:
sys.setdefaultencoding( "utf8" )
except LookupError:
pass
def __execPythonStartup():
try:
filename = os.environ.pop('__PYTHONSTARTUP__')
except KeyError:
os.environ.pop('PYTHONSTARTUP', None)
else:
os.environ['PYTHONSTARTUP'] = filename
if filename:
execfile(filename)
def __savePythonStartup():
try:
os.environ['__PYTHONSTARTUP__'] = os.environ['PYTHONSTARTUP']
except KeyError:
pass
os.environ['PYTHONSTARTUP'] = __file__
if __name__ == '__main__':
# Executing as PYTHONSETUP script
try:
import rlcompleter, readline
except ImportError:
pass
else:
__registerExitHandler()
__enableReadlineSupport()
__execPythonStartup()
else:
# Executing as sitecustomize
__enableDefaultEncoding()
__savePythonStartup()
main()
del main
- Platform Agent
- VOLTTRON Central Agent
- Platform Commands
- Platform Configuration
- [Platform Hardening Security Recommendations] (Linux-Platform-Hardening-Recommendations-for-VOLTTRON-users)
- ...
- [Building VOLTTRON] (Building-VOLTTRON)
- Example Agents
- Agent Development
- [Shortcut Scripts] (Scripts)
- [VOLTTRON Conventions] (Conventions)
- [sMAP Test Server] (sMAP-Test-Instance)
- [Design Discussions] (Design Discussions)
- VIP
- VIP - VOLTTRON Interconnect Protocol
- RPC by example
- VIP - Known Identities
- VIP - Authentication
- VIP - Authorization
- Protecting Pub/Sub Topics
- Setup Eclipse for VOLTTRON
- Deployment Walkthrough
- Forward Historian Walkthrough
- [Create New Historian Agent] (Developing-Historian-Agents)
- [Create New Driver Agent] (Develop-Driver-Agent)
- [Developing With Eclipse] (Eclipse)
- Migrations
- [2.x to 3.x Migration](2.x-to 3.x-Migration)
- 1.2 to 2.0 Migration
- [Deployment Recommendations](Recommendations for Deployments)
VOLTTRON Versions and Features
Transactional Network Platform Overview
- Established Topics
- Working with the Actuator Agent
- Logging
- [Multi-Node Communication] (MultiBuildingMessaging)
Information Exchange Standards