1
- #!/usr/bin/env python
2
1
# -*- coding: utf-8 -*-
3
2
4
3
from __future__ import print_function
@@ -343,7 +342,8 @@ def myreplacementclose(m):
343
342
else :
344
343
return m .group (0 )
345
344
346
- if compiledregexmungeopen .search (ad ):
345
+ mungeDetected = compiledregexmungeopen .search (ad )
346
+ if mungeDetected :
347
347
info ("detected AttrDict error in manifest" )
348
348
ad = compiledregexmungeopen .sub ("{" ,ad )
349
349
ad = compiledregexmungeclose .sub ("}" ,ad )
@@ -354,6 +354,9 @@ def myreplacementclose(m):
354
354
355
355
if (sys .version_info [0 ] >= 3 ):
356
356
ad = re .sub (r"'size': ([0-9]+)L," ,r"'size': \1," ,ad )
357
+ db = eval (ad )
358
+ if (mungeDetected ):
359
+ save_manifest (db )
357
360
return eval (ad )
358
361
except IOError :
359
362
return []
@@ -1008,7 +1011,6 @@ def process_argv(argv):
1008
1011
1009
1012
return args
1010
1013
1011
-
1012
1014
# --------
1013
1015
# Commands
1014
1016
# --------
@@ -1202,6 +1204,8 @@ def cmd_update(os_list, lang_list, skipknown, updateonly, partial, ids, skipids,
1202
1204
else :
1203
1205
info ('fetching game product data (page %d / %d)...' % (i , json_data ['totalPages' ]))
1204
1206
data_response = request (updateSession ,api_url ,args = {'mediaType' : media_type ,'sortBy' : 'title' ,'page' : str (i )})
1207
+ # with open("text.html","w+",encoding='utf-8') as f:
1208
+ # f.write(data_response.text)
1205
1209
try :
1206
1210
json_data = data_response .json ()
1207
1211
except ValueError :
@@ -1749,9 +1753,9 @@ def ioloop(tid, path, response, out):
1749
1753
responseTimer = threading .Timer (HTTP_TIMEOUT ,killresponse ,[response ])
1750
1754
responseTimer .start ()
1751
1755
except (requests .exceptions .ConnectionError ,requests .packages .urllib3 .exceptions .ProtocolError ) as e :
1752
- error ("server response issue while downloading content for %s" % (path ))
1756
+ error ("server response issue while downloading content for %s" % (path ))
1753
1757
except (OpenSSL .SSL .Error ) as e :
1754
- error ("SSL issue while downloading content for %s" % (path ))
1758
+ error ("SSL issue while downloading content for %s" % (path ))
1755
1759
responseTimer .cancel ()
1756
1760
#info("Exiting I/O Loop - " + path)
1757
1761
return dlsz
@@ -2486,7 +2490,6 @@ def update_self():
2486
2490
with open_notrunc ('rolling.tar.gz' ) as w :
2487
2491
w .write (rawResponse )
2488
2492
2489
-
2490
2493
def main (args ):
2491
2494
stime = datetime .datetime .now ()
2492
2495
@@ -2627,6 +2630,7 @@ def __init__(self):
2627
2630
self ._PMassertion = None
2628
2631
self ._PMassertID = ctypes .c_uint32 (0 )
2629
2632
self ._PMerrcode = None
2633
+ self ._IOPMAssertionRelease = self .libIOKit .IOPMAssertionRelease
2630
2634
2631
2635
2632
2636
def _CFSTR (self ,py_string ):
@@ -2639,7 +2643,7 @@ def _IOPMAssertionCreateWithName(self,assert_name, assert_level, assert_msg):
2639
2643
assertID = ctypes .c_uint32 (0 )
2640
2644
p_assert_name = self .raw_ptr (self ._CFSTR (assert_name ))
2641
2645
p_assert_msg = self .raw_ptr (self ._CFSTR (assert_msg ))
2642
- errcode = libIOKit .IOPMAssertionCreateWithName (p_assert_name ,
2646
+ errcode = self . libIOKit .IOPMAssertionCreateWithName (p_assert_name ,
2643
2647
assert_level , p_assert_msg , ctypes .byref (assertID ))
2644
2648
return (errcode , assertID )
2645
2649
@@ -2676,10 +2680,11 @@ def take_wakelock(self):
2676
2680
ctypes .windll .kernel32 .SetThreadExecutionState (self .ES_WAKELOCK )
2677
2681
if platform .system () == "Darwin" :
2678
2682
a = self .PM_WAKELOCK
2679
- if a != self ._PMassertion :
2680
- self .releaseWakelock ()
2681
- if self ._assertID .value == 0 :
2683
+ if self . _PMassertion is not None and a != self ._PMassertion :
2684
+ self .release_wakelock ()
2685
+ if self ._PMassertID .value == 0 :
2682
2686
self ._PMerrcode , self ._PMassertID = self ._IOPMAssertionCreateWithName (a ,self ._kIOPMAssertionLevelOn ,"gogrepoc" )
2687
+ self ._PMassertion = a
2683
2688
if (not (platform .system () == "Windows" or platform .system () == "Darwin" )) and ('PyQt5.QtDBus' in sys .modules ):
2684
2689
self .inhibitor = self ._get_inhibitor ()
2685
2690
self .inhibitor .inhibit ()
@@ -2688,8 +2693,9 @@ def release_wakelock(self):
2688
2693
if platform .system () == "Windows" :
2689
2694
ctypes .windll .kernel32 .SetThreadExecutionState (self .ES_CONTINUOUS )
2690
2695
if platform .system () == "Darwin" :
2691
- self ._PMerrcode = self ._IOPMAssertionRelease (self ._assertID )
2696
+ self ._PMerrcode = self ._IOPMAssertionRelease (self ._PMassertID )
2692
2697
self ._PMassertID .value = 0
2698
+ self ._PMassertion = None
2693
2699
2694
2700
class DBusSystemInhibitor :
2695
2701
0 commit comments