Changeset 1181:52dda2b6d0eb
- Timestamp:
- 12/29/24 13:34:24 (4 days ago)
- Branch:
- python3
- Phase:
- public
- Tags:
- tip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
setup.py
r1173 r1181 51 51 52 52 rootFiles = ["logo.png", "conn_grey.png", "conn_red.png", "conn_green.png", 53 "mavalogo.png", "fleet.json", "gates.json" ]53 "mavalogo.png", "fleet.json", "gates.json", "bugreport.txt"] 54 54 if os.name!="nt": 55 55 rootFiles.append("Microsoft.VC90.CRT.manifest") -
src/mlx/gui/gui.py
r1178 r1181 105 105 self._bookFlightsBusyCallback = None 106 106 107 self.webHandler = web.Handler(config, self._getCredentialsCallback) 107 self.webHandler = web.Handler(config, self._getCredentialsCallback, 108 programDirectory) 108 109 self.webHandler.start() 109 110 -
src/mlx/web.py
r1164 r1181 24 24 import certifi 25 25 import base64 26 import os.path 27 import ssl 26 28 27 29 #--------------------------------------------------------------------------------------- … … 723 725 #------------------------------------------------------------------------------ 724 726 727 class BugReportPasswordManager: 728 """Password manager for the Trac XML-RPC server""" 729 def __init__(self, programDirectory): 730 """Construct the password manager by reading the password from 731 the bugreport.txt file""" 732 with open(os.path.join(programDirectory, "bugreport.txt")) as f: 733 self._password = f.read().strip() 734 735 def add_password(self, realm, uri, username, password): 736 pass 737 738 def find_user_password(self, realm, uri): 739 return ("mlxbugreport", self._password) 740 741 #------------------------------------------------------------------------------ 742 743 class BugReportTransport(xmlrpc.client.Transport): 744 """A transport for digest authentication towards the Trac XML-RPC server""" 745 verbose = True 746 747 def __init__(self, programDirectory): 748 """Construct the transport for the given program directory.""" 749 super().__init__() 750 751 sslContext = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, 752 cafile = certifi.where()) 753 sslContext.set_alpn_protocols(['http/1.1']) 754 httpsHandler = urllib.request.HTTPSHandler(context = sslContext) 755 756 authHandler = urllib.request.HTTPDigestAuthHandler( 757 BugReportPasswordManager(programDirectory)) 758 759 self._opener = urllib.request.build_opener(httpsHandler, authHandler) 760 761 def single_request(self, host, handler, request_body, verbose=False): 762 """Perform a single request""" 763 url = "https://" + host + handler 764 request = urllib.request.Request(url, data = request_body) 765 request.add_header("User-Agent", self.user_agent) 766 request.add_header("Content-Type", "text/xml") 767 768 with self._opener.open(request) as f: 769 if f.status==200: 770 return self.parse_response(f) 771 else: 772 raise xmlrpc.client.ProtocolError( 773 host + handler, 774 f.status, f.reason, 775 f.getheaders()) 776 777 #------------------------------------------------------------------------------ 778 725 779 class SendBugReport(Request): 726 780 """A request to send a bug report to the project homepage.""" 727 781 _latin2Encoder = codecs.getencoder("iso-8859-2") 728 782 729 def __init__(self, callback, summary, description, email, debugLog): 783 def __init__(self, callback, summary, description, email, debugLog, 784 transport): 730 785 """Construct the request for the given bug report.""" 731 786 super(SendBugReport, self).__init__(callback) … … 734 789 self._email = email 735 790 self._debugLog = debugLog 791 self._transport = transport 736 792 737 793 def run(self): 738 794 """Perform the sending of the bug report.""" 739 serverProxy = xmlrpc.client.ServerProxy("http ://mlx.varadiistvan.hu/rpc")740 795 serverProxy = xmlrpc.client.ServerProxy("https://mlx.varadiistvan.hu/login/rpc", 796 transport = self._transport) 741 797 result = Result() 742 798 result.success = False … … 905 961 It can process one request at a time. The results are passed to a callback 906 962 function.""" 907 def __init__(self, config, getCredentialsFn ):963 def __init__(self, config, getCredentialsFn, programDirectory): 908 964 """Construct the handler.""" 909 965 super(Handler, self).__init__() … … 917 973 if config.rememberPassword: 918 974 self._rpcClient.setCredentials(config.pilotID, config.password) 975 self._bugReportTransport = BugReportTransport(programDirectory) 919 976 920 977 def register(self, callback, registrationData): … … 964 1021 """Send a bug report with the given data.""" 965 1022 self._addRequest(SendBugReport(callback, summary, description, email, 966 debugLog = debugLog)) 1023 debugLog = debugLog, 1024 transport = self._bugReportTransport)) 967 1025 968 1026 def setCheckFlightPassed(self, callback, aircraftType):
Note:
See TracChangeset
for help on using the changeset viewer.