1
1
import sys
2
2
import PyQt4.QtCore as QtCore
3
- from PyQt4.QtGui import QDialog, QDialogButtonBox, QApplication, QLabel, QVBoxLayout, QImage, QPixmap
3
+ from PyQt4.QtGui import QDialog, QDialogButtonBox, QApplication, \
4
+ QLabel, QVBoxLayout, QImage, QPixmap
4
5
from PyQt4.QtCore import Qt
5
6
import os
6
- import errno
7
7
import threading
8
8
import pipereader
9
9
10
+
10
11
class SDDialog(QDialog):
11
- def __init__(self, parent = None):
12
+ def __init__(self, parent= None):
12
13
fn = r'/usr/local/share/sd/logo-small.png'
13
14
image = QImage(fn)
14
15
self.logo = QLabel()
@@ -36,32 +37,47 @@ class SDDialog(QDialog):
36
37
37
38
messages = {
38
39
# bootstrapping
39
- 'EXISTING_SIGFILE': ("error", "Internal error: signal file given by caller already exists"),
40
- 'POLLING_ERROR': {"error": "An internal error occurred while listening for events from VMs."},
40
+ 'EXISTING_SIGFILE': (
41
+ "error", "Internal error: signal file given by caller already exists"),
42
+ 'POLLING_ERROR': {
43
+ "error": ("An internal error occurred while listening"
44
+ " for events from VMs.")},
41
45
42
46
# sd-journalist
43
- 'DOWNLOAD_FILE_MISSING': ("error", "The file downloaded from SecureDrop wasn't found."),
47
+ 'DOWNLOAD_FILE_MISSING': (
48
+ "error", "The file downloaded from SecureDrop wasn't found."),
44
49
'DOWNLOAD_BUNDLE_CREATED': ("success", "Initial download bundle created."),
45
50
46
51
# decrypt
47
52
'DECRYPTION_PROCESS_START': ("success", "Decryption process started."),
48
- 'DECRYPTION_BUNDLE_OPEN_FAILURE': ("error", "Decryption bundle could not be opened."),
49
- 'SUBMISSION_BUNDLE_UNBUNDLED': ("success", "Submission bundle looks valid."),
50
- 'SUBMISSION_FILES_EXTRACTED': ("success", "Submission bundle files extracted."),
51
- 'SUBMISSION_FILE_DECRYPTION_FAILED': ('error', "Submission file decryption failed."),
52
- 'SUBMISSION_FILE_DECRYPTION_SUCCEEDED': ("success", "Submission file decrypted."),
53
- 'SUBMISSION_DECRYPTED': ("success", "All submission files decrypted"),
53
+ 'DECRYPTION_BUNDLE_OPEN_FAILURE':
54
+ ("error", "Decryption bundle could not be opened."),
55
+ 'SUBMISSION_BUNDLE_UNBUNDLED':
56
+ ("success", "Submission bundle looks valid."),
57
+ 'SUBMISSION_FILES_EXTRACTED':
58
+ ("success", "Submission bundle files extracted."),
59
+ 'SUBMISSION_FILE_DECRYPTION_FAILED':
60
+ ('error', "Submission file decryption failed."),
61
+ 'SUBMISSION_FILE_DECRYPTION_SUCCEEDED':
62
+ ("success", "Submission file decrypted."),
63
+ 'SUBMISSION_DECRYPTED':
64
+ ("success", "All submission files decrypted"),
54
65
55
66
# SVS
56
- 'DECRYPTED_BUNDLE_ON_SVS': ("success", "Decrypted file bundle arrived on SVS."),
57
- 'DECRYPTED_FILES_AVAILABLE': ("success", "Submitted files available for use on SVS."),
58
- 'DECRYPTED_BUNDLE UNBUNDLE_ERROR': ("error", "Bundle of decrypted files could not be unbundle on SVS." )
67
+ 'DECRYPTED_BUNDLE_ON_SVS':
68
+ ("success", "Decrypted file bundle arrived on SVS."),
69
+ 'DECRYPTED_FILES_AVAILABLE':
70
+ ("success", "Submitted files available for use on SVS."),
71
+ 'DECRYPTED_BUNDLE UNBUNDLE_ERROR':
72
+ ("error", "Bundle of decrypted files could not be unbundle on SVS.")
59
73
}
60
74
75
+
61
76
def finish():
62
77
d.buttons.hide()
63
78
d.layout.removeWidget(d.buttons)
64
79
80
+
65
81
def display(keyword):
66
82
67
83
if keyword in messages:
@@ -70,6 +86,7 @@ def display(keyword):
70
86
# XXX dev only, remove before deploying!
71
87
d.display.setText("bad keyword: {}".format(keyword))
72
88
89
+
73
90
def poller_cb(poller, msg, err):
74
91
# we're called with a keyword in `msg`. We look up that keyword
75
92
# for the user-facing message to display.
@@ -90,9 +107,9 @@ def create_sigfile(sigfile):
90
107
display('EXISTING_SIGFILE')
91
108
else:
92
109
try:
93
- with open(sigfile,'a'):
110
+ with open(sigfile, 'a'):
94
111
pass
95
- except Exception as e :
112
+ except Exception:
96
113
display('BAD_SIGFILE')
97
114
98
115
@@ -111,7 +128,7 @@ if __name__ == '__main__':
111
128
d.show()
112
129
113
130
if sigfile != "":
114
- # tyvm https://stackoverflow.com/questions/6215690/how-to-execute-a-method-automatically-after-entering-qt-event-loop
131
+ # tyvm https://stackoverflow.com/questions/6215690/how-to-execute-a-method-automatically-after-entering-qt-event-loop # noqa: E501
115
132
def on_start():
116
133
create_sigfile(sigfile)
117
134
0 commit comments