[Pydev-cvs] org.python.pydev/PySrc/pydev_sitecustomize sitecustomize.py, 1.1, 1.2
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-04-28 23:04:45
|
Update of /cvsroot/pydev/org.python.pydev/PySrc/pydev_sitecustomize In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8103/PySrc/pydev_sitecustomize Modified Files: sitecustomize.py Log Message: Encoding passed with environment variable bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1950217&group_id=85796&atid=577329 Index: sitecustomize.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/pydev_sitecustomize/sitecustomize.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sitecustomize.py 7 Apr 2008 00:52:02 -0000 1.1 --- sitecustomize.py 28 Apr 2008 23:03:41 -0000 1.2 *************** *** 15,58 **** #----------------------------------------------------------------------------------------------------------------------- #check if the encoding has been specified for this launch... - config_file_str = os.path.dirname(__file__) - config_file_str = os.path.join(config_file_str, 'encoding_config') #set the encoding with the encoding_config file that should've been created #before launching the last application (it'll be removed after we get its contents) ! if os.path.exists(config_file_str): ! try: ! config_file = open(config_file_str, 'r') ! except: if DEBUG: ! import traceback;traceback.print_exc() #@Reimport ! ! else: ! #ok, file opened ! try: ! try: ! new_encoding = config_file.read() ! if new_encoding.strip(): ! encoding = new_encoding.strip() ! if DEBUG: ! print 'encoding read: ', encoding ! except: ! #ok, just ignore it if we couldn't get it ! if DEBUG: ! import traceback;traceback.print_exc() #@Reimport - finally: - try: - config_file.close() - except: - if DEBUG: - import traceback;traceback.print_exc() #@Reimport - - try: - #remove the file (it's valid only for a single launch) - os.remove(config_file_str) - except: - if DEBUG: - import traceback;traceback.print_exc() #@Reimport - --- 15,32 ---- #----------------------------------------------------------------------------------------------------------------------- #check if the encoding has been specified for this launch... #set the encoding with the encoding_config file that should've been created #before launching the last application (it'll be removed after we get its contents) ! try: ! new_encoding = os.environ.get('PYDEV_CONSOLE_ENCODING') ! if new_encoding and new_encoding.strip(): ! encoding = new_encoding.strip() if DEBUG: ! print 'encoding from env (PYDEV_CONSOLE_ENCODING): ', encoding ! except: ! #ok, just ignore it if we couldn't get it ! if DEBUG: ! import traceback;traceback.print_exc() #@Reimport *************** *** 67,70 **** --- 41,46 ---- #that's the way that the encoding is specified in WorkbenchEncoding.getWorkbenchDefaultEncoding encoding = System.getProperty("file.encoding", "") + if DEBUG: + print 'encoding from "file.encoding": ', encoding *************** *** 82,85 **** --- 58,63 ---- #ok, default locale is set (if the user didn't specify any encoding, the system default should be used) encoding = loc[1] + if DEBUG: + print 'encoding from "locale": ', encoding *************** *** 95,98 **** --- 73,78 ---- try: if encoding: + if DEBUG: + print 'Setting default encoding', encoding sys.setdefaultencoding(encoding) #@UndefinedVariable (it's deleted after the site.py is executed -- so, it's undefined for code-analysis) except: |