[Opensrf-commits] r2083 - trunk/src/python (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Nov 15 22:29:34 EST 2010
Author: erickson
Date: 2010-11-15 22:29:32 -0500 (Mon, 15 Nov 2010)
New Revision: 2083
Modified:
trunk/src/python/srfsh.py
Log:
killed the terminal colors in srfsh.py output. They are cute and all, but are likely the cause of readline oddities/artifacts (and kind of distracting). Default to raw (json) output for consistency
Modified: trunk/src/python/srfsh.py
===================================================================
--- trunk/src/python/srfsh.py 2010-11-15 21:10:06 UTC (rev 2082)
+++ trunk/src/python/srfsh.py 2010-11-16 03:29:32 UTC (rev 2083)
@@ -32,8 +32,7 @@
while True:
try:
- #line = raw_input("srfsh% ")
- line = raw_input("\033[01;32msrfsh\033[01;34m% \033[00m")
+ line = raw_input("srfsh% ")
if not len(line):
continue
if str.lower(line) == 'exit' or str.lower(line) == 'quit':
@@ -135,6 +134,7 @@
break
total = time.time() - start
+ print str(resp.content())
otp = get_var('SRFSH_OUTPUT')
if otp == 'pretty':
print "\n" + osrf.json.debug_net_object(resp.content())
@@ -225,9 +225,9 @@
def do_connect():
file = os.path.join(get_var('HOME'), ".srfsh.xml")
- print_green("Connecting to opensrf...")
+ print_stdout("Connecting to opensrf...")
osrf.system.System.connect(config_file=file, config_context='srfsh')
- print_red('OK\n')
+ print_stdout('OK\n')
def load_plugins():
# Load the user defined external plugins
@@ -237,7 +237,7 @@
except:
# XXX standard srfsh.xml does not yet define <plugins> element
- print_red("No plugins defined in /srfsh/plugins/plugin\n")
+ #print_stdout("No plugins defined in /srfsh/plugins/plugin\n")
return
plugins = osrf.conf.get('plugins.plugin')
@@ -247,19 +247,19 @@
for module in plugins:
name = module['module']
init = module['init']
- print_green("Loading module %s..." % name)
+ print_stdout("Loading module %s..." % name)
try:
string = 'import %s\n%s.%s()' % (name, name, init)
exec(string)
- print_red('OK\n')
+ print_stdout('OK\n')
except Exception, e:
sys.stderr.write("\nError importing plugin %s, with init symbol %s: \n%s\n" % (name, init, e))
def set_vars():
if not get_var('SRFSH_OUTPUT'):
- set_var('SRFSH_OUTPUT', 'pretty')
+ set_var('SRFSH_OUTPUT', 'raw')
# XXX Do we need to differ between LANG and LC_MESSAGES?
if not get_var('SRFSH_LOCALE'):
@@ -299,19 +299,11 @@
return locale
-def print_green(string):
- sys.stdout.write("\033[01;32m")
+def print_stdout(string):
sys.stdout.write(string)
- sys.stdout.write("\033[00m")
sys.stdout.flush()
-def print_red(string):
- sys.stdout.write("\033[01;31m")
- sys.stdout.write(string)
- sys.stdout.write("\033[00m")
- sys.stdout.flush()
-
if __name__ == '__main__':
# Kick it off
More information about the opensrf-commits
mailing list