Общие сессии для cl-console-gui и cl-console

master-3.5 3.5.0_alpha17
parent 9d990c6f3f
commit f770ca4eb7

@ -203,6 +203,7 @@ class Client_suds(Client):
self.REQ_FILE = path_to_cert + 'client.csr'
self.PKEY_FILE = PKEY_FILE
self.SID_FILE = path_to_cert + 'sids'
self.SID_LOCK = path_to_cert + 'sids.lock'
self.CRL_PATH = path_to_cert + 'ca/crl/'
if not os.path.exists(self.CRL_PATH):
os.makedirs(self.CRL_PATH)
@ -237,11 +238,11 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
while True:
if os.path.exists(user_root_cert):
result_user_root = self.connect_trusted_root(sock, \
result_user_root = self.connect_trusted_root(sock,
user_root_cert, self.CRL_PATH)
if result_user_root == 1:
glob_root_cert = self.ClientObj.VarsApi.Get \
('core.cl_glob_root_cert')
glob_root_cert = self.ClientObj.VarsApi.Get(
'core.cl_glob_root_cert')
result_root_con = 1
if os.path.exists(glob_root_cert):
sock = socket.create_connection((self.host, self.port),
@ -249,7 +250,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
if self._tunnel_host:
self.sock = sock
self._tunnel()
result_root_con = self.connect_trusted_root(sock, \
result_root_con = self.connect_trusted_root(sock,
glob_root_cert, self.CRL_PATH)
if result_root_con == 1:
sock = socket.create_connection((self.host, self.port),
@ -257,8 +258,8 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
if self._tunnel_host:
self.sock = sock
self._tunnel()
result_server_con = self.connect_trusted_server \
(sock, self.CRL_PATH)
result_server_con = self.connect_trusted_server(
sock, self.CRL_PATH)
if result_server_con in [1,2]:
raise Exception (1)
elif result_server_con == 3:

@ -27,7 +27,7 @@ from PIL import Image
from calculate.lib.utils.files import listDirectory
from calculate.lib.utils.colortext.palette import (
GuiPalette as WorkPalette)
from calculate.update.update_info import UpdateInfo
from calculate.lib.utils.tools import Locker
ParameterWindow = QtGui.QPalette.Window
@ -2620,22 +2620,23 @@ def client_list_methods(sid, client):
# get session id
def get_sid (client):
SID_FILE = client.SID_FILE
server_host_name = client.server_host_name
if not os.path.exists(SID_FILE) :
fs = open(SID_FILE, 'w')
fs.write('%s 0\n' %server_host_name)
fs.close()
else:
fs = open(SID_FILE, 'r')
lines = fs.readlines()
fs.close()
for line in lines:
word = line.split()
if word:
if word[0] == server_host_name:
sid = int (word[1])
return sid
return 0
with Locker(fn=client.SID_LOCK):
server_host_name = client.server_host_name
if not os.path.exists(SID_FILE):
fs = open(SID_FILE, 'w')
fs.write('%s 0\n' %server_host_name)
fs.close()
else:
fs = open(SID_FILE, 'r')
lines = fs.readlines()
fs.close()
for line in lines:
word = line.split()
if word:
if word[0] == server_host_name:
sid = int (word[1])
return sid
return 0
class ClientServiceThread(QtCore.QThread):
signal = QtCore.Signal(object)

@ -13,9 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from PySide import QtGui, QtCore
import urllib2
from calculate.lib.utils.tools import Locker
from more import show_msg, LabelWordWrap, get_ip_mac, get_sid
@ -27,23 +28,24 @@ def client_sid(sid, client, cert_id, lang):
server_host_name = client.server_host_name
find_flag = False
fs = open(client.SID_FILE, 'r')
lines = fs.readlines()
fs.close()
fi = open(client.SID_FILE, 'w')
for line in lines:
word = line.split()
if word:
if word[0] == server_host_name:
find_flag = True
line = '%s %s\n' %(word[0], sid)
fi.write(line)
if not find_flag:
fi = open(client.SID_FILE, 'a')
fi.write('%s %s\n' %(server_host_name, sid))
fi.close()
with Locker(fn=client.SID_LOCK):
fs = open(client.SID_FILE, 'r')
lines = fs.readlines()
fs.close()
fi = open(client.SID_FILE, 'w')
for line in lines:
word = line.split()
if word:
if word[0] == server_host_name:
find_flag = True
line = '%s %s\n' %(word[0], sid)
fi.write(line)
if not find_flag:
fi = open(client.SID_FILE, 'a')
fi.write('%s %s\n' %(server_host_name, sid))
fi.close()
# if new_sid[0][1] == 1:
return [sid, new_sid[0][1]]
@ -75,7 +77,7 @@ class ViewSessionInfo (QtGui.QWidget):
def __init__(self, parent, client, window):
QtGui.QWidget.__init__(self)
self.layout = QtGui.QGridLayout()
sid = get_sid(client)
try:
results = client.service.post_cert()
@ -83,9 +85,9 @@ class ViewSessionInfo (QtGui.QWidget):
self.layout.addWidget(LabelWordWrap (_('Not connected!')))
self.setLayout(self.layout)
return 1
ip, mac = get_ip_mac()
if results[0][0] == -4:
self.layout.addWidget(LabelWordWrap(_('Certificate not found in'
' the server!'), self), 0,0,1,2)

Loading…
Cancel
Save