comparison bin/sat @ 3028:ab2696e34d29

Python 3 port: /!\ this is a huge commit /!\ starting from this commit, SàT is needs Python 3.6+ /!\ SàT maybe be instable or some feature may not work anymore, this will improve with time This patch port backend, bridge and frontends to Python 3. Roughly this has been done this way: - 2to3 tools has been applied (with python 3.7) - all references to python2 have been replaced with python3 (notably shebangs) - fixed files not handled by 2to3 (notably the shell script) - several manual fixes - fixed issues reported by Python 3 that where not handled in Python 2 - replaced "async" with "async_" when needed (it's a reserved word from Python 3.7) - replaced zope's "implements" with @implementer decorator - temporary hack to handle data pickled in database, as str or bytes may be returned, to be checked later - fixed hash comparison for password - removed some code which is not needed anymore with Python 3 - deactivated some code which needs to be checked (notably certificate validation) - tested with jp, fixed reported issues until some basic commands worked - ported Primitivus (after porting dependencies like urwid satext) - more manual fixes
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:08:41 +0200
parents 26edcf3a30eb
children 8b36e5c3f28f
comparison
equal deleted inserted replaced
3027:ff5bcb12ae60 3028:ab2696e34d29
1 #!/bin/sh 1 #!/bin/sh
2 2
3 DEBUG="" 3 DEBUG=""
4 DAEMON="" 4 DAEMON=""
5 PYTHON="python2" 5 PYTHON="python3"
6 TWISTD="$(which twistd)" 6 TWISTD="$(which twistd)"
7 7
8 kill_process() { 8 kill_process() {
9 # $1 is the file containing the PID to kill, $2 is the process name 9 # $1 is the file containing the PID to kill, $2 is the process name
10 if [ -f $1 ]; then 10 if [ -f $1 ]; then
27 27
28 #We use python to parse config files 28 #We use python to parse config files
29 eval `"$PYTHON" << PYTHONEND 29 eval `"$PYTHON" << PYTHONEND
30 from sat.core.constants import Const as C 30 from sat.core.constants import Const as C
31 from sat.memory.memory import fixLocalDir 31 from sat.memory.memory import fixLocalDir
32 from ConfigParser import SafeConfigParser 32 from configparser import ConfigParser
33 from os.path import expanduser, join 33 from os.path import expanduser, join
34 import sys 34 import sys
35 import codecs
36 import locale
37
38 sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
39 35
40 fixLocalDir() # XXX: tmp update code, will be removed in the future 36 fixLocalDir() # XXX: tmp update code, will be removed in the future
41 37
42 config = SafeConfigParser(defaults=C.DEFAULT_CONFIG) 38 config = ConfigParser(defaults=C.DEFAULT_CONFIG)
43 try: 39 try:
44 config.read(C.CONFIG_FILES) 40 config.read(C.CONFIG_FILES)
45 except: 41 except:
46 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";") 42 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
47 print ("exit 1") 43 print ("exit 1")
50 env=[] 46 env=[]
51 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) 47 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
52 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),'')) 48 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),''))
53 env.append("APP_NAME='%s'" % C.APP_NAME) 49 env.append("APP_NAME='%s'" % C.APP_NAME)
54 env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE) 50 env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE)
55 print ";".join(env) 51 print (";".join(env))
56 PYTHONEND 52 PYTHONEND
57 ` 53 `
58 APP_NAME="$APP_NAME" 54 APP_NAME="$APP_NAME"
59 PID_FILE="$PID_DIR$APP_NAME_FILE.pid" 55 PID_FILE="$PID_DIR$APP_NAME_FILE.pid"
60 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log" 56 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log"