@@ -42,28 +42,28 @@ VERSION="20091224"
42
42
LOG_FILENAME = 'webkit2png.log'
43
43
logger = logging .getLogger ('webkit2png' );
44
44
45
- def init_qtgui (display = None , style = None , qtargs = [] ):
45
+ def init_qtgui (display = None , style = None , qtargs = None ):
46
46
"""Initiates the QApplication environment using the given args."""
47
47
if QApplication .instance ():
48
48
logger .debug ("QApplication has already been instantiated. \
49
49
Ignoring given arguments and returning existing QApplication." )
50
50
return QApplication .instance ()
51
-
51
+
52
52
qtargs2 = [sys .argv [0 ]]
53
-
53
+
54
54
if display :
55
55
qtargs2 .append ('-display' )
56
56
qtargs2 .append (display )
57
57
# Also export DISPLAY var as this may be used
58
58
# by flash plugin
59
59
os .environ ["DISPLAY" ] = display
60
-
60
+
61
61
if style :
62
62
qtargs2 .append ('-style' )
63
63
qtargs2 .append (style )
64
-
65
- qtargs2 .extend (qtargs )
66
-
64
+
65
+ qtargs2 .extend (qtargs or [] )
66
+
67
67
return QApplication (qtargs2 )
68
68
69
69
@@ -75,7 +75,7 @@ if __name__ == '__main__':
75
75
proxy_url = urlparse .urlparse (os .environ .get ('http_proxy' ))
76
76
proxy = QNetworkProxy (QNetworkProxy .HttpProxy , proxy_url .hostname , proxy_url .port )
77
77
QNetworkProxy .setApplicationProxy (proxy )
78
-
78
+
79
79
# Parse command line arguments.
80
80
# Syntax:
81
81
# $0 [--xvfb|--display=DISPLAY] [--debug] [--output=FILENAME] <URL>
@@ -113,6 +113,8 @@ if __name__ == '__main__':
113
113
help = "Render output on a transparent background (Be sure to have a transparent background defined in the html)" , default = False )
114
114
parser .add_option ("" , "--style" , dest = "style" ,
115
115
help = "Change the Qt look and feel to STYLE (e.G. 'windows')." , metavar = "STYLE" )
116
+ parser .add_option ("" , "--encoded-url" , dest = "encoded_url" , action = "store_true" ,
117
+ help = "Treat URL as url-encoded" , metavar = "ENCODED_URL" , default = False )
116
118
parser .add_option ("-d" , "--display" , dest = "display" ,
117
119
help = "Connect to X server at DISPLAY." , metavar = "DISPLAY" )
118
120
parser .add_option ("--debug" , action = "store_true" , dest = "debug" ,
@@ -154,8 +156,8 @@ if __name__ == '__main__':
154
156
print >> sys .stderr , "Error - Unable to find '%s' for -x/--xvfb option" % newArgs [0 ]
155
157
sys .exit (1 )
156
158
157
- # Prepare outout ("1" means STDOUT)
158
- if options .output == None :
159
+ # Prepare output ("1" means STDOUT)
160
+ if options .output is None :
159
161
options .output = sys .stdout
160
162
else :
161
163
options .output = open (options .output , "w" )
@@ -181,6 +183,7 @@ if __name__ == '__main__':
181
183
renderer .format = options .format
182
184
renderer .grabWholeWindow = options .window
183
185
renderer .renderTransparentBackground = options .transparent
186
+ renderer .encodedUrl = options .encoded_url
184
187
185
188
if options .scale :
186
189
renderer .scaleRatio = options .ratio
0 commit comments