@@ -100,31 +100,34 @@ def checkRPCstring(urlstring, action_msg="Malformed credentials"):
100100
101101
102102
103- def clean_v4_migration (db ):
104- try :
105- rpc_file = os .path .join (user_dir , 'rpcServer .json' )
106- cache_file = os .path .join (user_dir , 'cache .json' )
107- mn_file = os . path . join ( user_dir , 'masternodes.json' )
108-
109- if os .path .exists (rpc_file ) or os .path .exists (cache_file ) or os .path .exists (mn_file ):
110- printDbg ("Clean migration to v0.4.0 data storage" )
111-
112- if os .path .exists (rpc_file ):
113- # If RPC file exists
114- printDbg ( "found old rpcServer.json file" )
103+ def clean_v4_migration (wnd ):
104+ rpc_file = os . path . join ( user_dir , 'rpcServer.json' )
105+ cache_file = os .path .join (user_dir , 'cache .json' )
106+ mn_file = os .path .join (user_dir , 'masternodes .json' )
107+ messTitle = "Clean migration to v0.4.0 data storage"
108+
109+ if os .path .exists (rpc_file ) or os .path .exists (cache_file ) or os .path .exists (mn_file ):
110+ printDbg (messTitle )
111+
112+ if os .path .exists (rpc_file ):
113+ # If RPC file exists
114+ try :
115115 with open (rpc_file ) as data_file :
116116 rpc_config = json .load (data_file )
117117 # copy to database
118118 rpc_host = "%s:%d" % (rpc_config ['rpc_ip' ], rpc_config ['rpc_port' ])
119- db .editRPCServer ("http" , rpc_host , rpc_config ['rpc_user' ], rpc_config ['rpc_password' ], 0 )
119+ wnd . db .editRPCServer ("http" , rpc_host , rpc_config ['rpc_user' ], rpc_config ['rpc_password' ], 0 )
120120 printDbg ("...saved to Database" )
121121 # and delete old file
122122 os .remove (rpc_file )
123123 printDbg ("old rpcServer.json file deleted" )
124-
125- if os .path .exists (cache_file ):
126- # If cache file exists
127- printDbg ("found old cache.json file" )
124+ except Exception as e :
125+ mess = "Error importing old rpc_config file"
126+ printException (getCallerName (), getFunctionName (), mess , e )
127+
128+ if os .path .exists (cache_file ):
129+ # If cache file exists
130+ try :
128131 with open (cache_file ) as data_file :
129132 cache = json .load (data_file )
130133 # copy to Settings
@@ -133,23 +136,25 @@ def clean_v4_migration(db):
133136 # and delete old file
134137 os .remove (cache_file )
135138 printDbg ("old cache.json file deleted" )
136-
137- if os .path .exists (mn_file ):
138- # If mn file exists
139- printDbg ("found old masternodes.json file" )
139+ except Exception as e :
140+ mess = "Error importing old cache file"
141+ printException (getCallerName (), getFunctionName (), mess , e )
142+
143+ if os .path .exists (mn_file ):
144+ # If mn file exists
145+ try :
140146 with open (mn_file ) as data_file :
141147 mnList = json .load (data_file )
142148 # add to database
143149 for mn in mnList :
144- db .addMasternode (mn )
150+ wnd . db .addMasternode (mn )
145151 printDbg ("...saved to Database" )
146152 # and delete old file
147153 os .remove (mn_file )
148- printDbg ("old masternodes.json file deleted" )
149-
150- except Exception as e :
151- printDbg (e )
152-
154+ printDbg ("old masternodes.json file deleted" )
155+ except Exception as e :
156+ mess = "Error importing old masternodes_config file"
157+ printException (getCallerName (), getFunctionName (), mess , e )
153158
154159
155160
@@ -442,24 +447,22 @@ def removeMNfromList(mainWnd, mn, removeFromDB=True):
442447def saveCacheSettings (cache , old_version = False ):
443448 settings = QSettings ('PIVX' , 'SecurePivxMasternodeTool' )
444449 settings .setValue ('cache_lastAddress' , cache .get ('lastAddress' ))
445- settings .setValue ('cache_winWidth' , cache .get ('window_width' ))
446- settings .setValue ('cache_winHeight' , cache .get ('window_height' ))
447- if old_version :
448- settings .setValue ('cache_splitterX' , cache .get ('splitter_sizes' )[0 ])
449- settings .setValue ('cache_splitterY' , cache .get ('splitter_sizes' )[1 ])
450- else :
451- settings .setValue ('cache_splitterX' , cache .get ('splitter_x' ))
452- settings .setValue ('cache_splitterY' , cache .get ('splitter_y' ))
453- settings .setValue ('cache_mnOrder' , json .dumps (cache .get ('mnList_order' )))
454- settings .setValue ('cache_consoleHidden' , cache .get ('console_hidden' ))
455450 settings .setValue ('cache_useSwiftX' , cache .get ('useSwiftX' ))
456- settings .setValue ('cache_votingMNs' , json .dumps (cache .get ('votingMasternodes' )))
457451 settings .setValue ('cache_vdCheck' , cache .get ('votingDelayCheck' ))
458452 settings .setValue ('cache_vdNeg' , cache .get ('votingDelayNeg' ))
459453 settings .setValue ('cache_vdPos' , cache .get ('votingDelayPos' ))
460- if not old_version :
461- settings .setValue ('cache_RPCindex' , cache .get ('selectedRPC_index' ))
462- settings .setValue ('cache_MNcount' , cache .get ('MN_count' ))
454+ # that's enough for clean_v4_migration
455+ if old_version :
456+ return
457+ settings .setValue ('cache_winWidth' , cache .get ('window_width' ))
458+ settings .setValue ('cache_winHeight' , cache .get ('window_height' ))
459+ settings .setValue ('cache_splitterX' , cache .get ('splitter_x' ))
460+ settings .setValue ('cache_splitterY' , cache .get ('splitter_y' ))
461+ settings .setValue ('cache_mnOrder' , json .dumps (cache .get ('mnList_order' )))
462+ settings .setValue ('cache_consoleHidden' , cache .get ('console_hidden' ))
463+ settings .setValue ('cache_votingMNs' , json .dumps (cache .get ('votingMasternodes' )))
464+ settings .setValue ('cache_RPCindex' , cache .get ('selectedRPC_index' ))
465+ settings .setValue ('cache_MNcount' , cache .get ('MN_count' ))
463466
464467
465468
0 commit comments