Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced path Dependency from network package #2260

Draft
wants to merge 1 commit into
base: v0.6
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/network/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import sys

import network.asyncore_pollchoose as asyncore
import paths
from network.advanceddispatcher import AdvancedDispatcher
from queues import receiveDataQueue

Expand Down Expand Up @@ -49,9 +48,9 @@ def __init__(self, _=None, sock=None, certfile=None, keyfile=None,
server_side=False, ciphers=sslProtocolCiphers):
self.want_read = self.want_write = True
self.certfile = certfile or os.path.join(
paths.codePath(), 'sslkeys', 'cert.pem')
self._codePath(), 'sslkeys', 'cert.pem')
self.keyfile = keyfile or os.path.join(
paths.codePath(), 'sslkeys', 'key.pem')
self._codePath(), 'sslkeys', 'key.pem')
self.server_side = server_side
self.ciphers = ciphers
self.tlsStarted = False
Expand Down Expand Up @@ -218,3 +217,13 @@ def tls_handshake(self):
self.set_state("connection_fully_established")
receiveDataQueue.put(self.destination)
return False

def _codePath(self): # pylint: disable=no-self-use
"""Returns project dir path"""
frozen = getattr(sys, 'frozen', None)
if not frozen:
return os.path.dirname(os.path.dirname(__file__))
return (
os.environ.get('RESOURCEPATH')
# pylint: disable=protected-access, no-member
if frozen == "macosx_app" else sys._MEIPASS)