V0.6 #852
|
@ -2708,18 +2708,18 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if shared.appdata != '' and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
|
if shared.appdata != '' and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
|
||||||
# Write the keys.dat file to disk in the new location
|
# Write the keys.dat file to disk in the new location
|
||||||
sqlStoredProcedure('movemessagstoprog')
|
sqlStoredProcedure('movemessagstoprog')
|
||||||
with open('keys.dat', 'wb') as configfile:
|
with open(shared.lookupExeFolder() + 'keys.dat', 'wb') as configfile:
|
||||||
shared.config.write(configfile)
|
shared.config.write(configfile)
|
||||||
# Write the knownnodes.dat file to disk in the new location
|
# Write the knownnodes.dat file to disk in the new location
|
||||||
shared.knownNodesLock.acquire()
|
shared.knownNodesLock.acquire()
|
||||||
output = open('knownnodes.dat', 'wb')
|
output = open(shared.lookupExeFolder() + 'knownnodes.dat', 'wb')
|
||||||
pickle.dump(shared.knownNodes, output)
|
pickle.dump(shared.knownNodes, output)
|
||||||
output.close()
|
output.close()
|
||||||
shared.knownNodesLock.release()
|
shared.knownNodesLock.release()
|
||||||
os.remove(shared.appdata + 'keys.dat')
|
os.remove(shared.appdata + 'keys.dat')
|
||||||
os.remove(shared.appdata + 'knownnodes.dat')
|
os.remove(shared.appdata + 'knownnodes.dat')
|
||||||
previousAppdataLocation = shared.appdata
|
previousAppdataLocation = shared.appdata
|
||||||
shared.appdata = ''
|
shared.appdata = shared.lookupExeFolder()
|
||||||
debug.restartLoggingInUpdatedAppdataLocation()
|
debug.restartLoggingInUpdatedAppdataLocation()
|
||||||
try:
|
try:
|
||||||
os.remove(previousAppdataLocation + 'debug.log')
|
os.remove(previousAppdataLocation + 'debug.log')
|
||||||
|
@ -2740,12 +2740,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
pickle.dump(shared.knownNodes, output)
|
pickle.dump(shared.knownNodes, output)
|
||||||
output.close()
|
output.close()
|
||||||
shared.knownNodesLock.release()
|
shared.knownNodesLock.release()
|
||||||
os.remove('keys.dat')
|
os.remove(shared.lookupExeFolder() + 'keys.dat')
|
||||||
os.remove('knownnodes.dat')
|
os.remove(shared.lookupExeFolder() + 'knownnodes.dat')
|
||||||
debug.restartLoggingInUpdatedAppdataLocation()
|
debug.restartLoggingInUpdatedAppdataLocation()
|
||||||
try:
|
try:
|
||||||
os.remove('debug.log')
|
os.remove(shared.lookupExeFolder() + 'debug.log')
|
||||||
os.remove('debug.log.1')
|
os.remove(shared.lookupExeFolder() + 'debug.log.1')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -501,8 +501,8 @@ class sqlThread(threading.Thread):
|
||||||
return
|
return
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
shutil.move(
|
shutil.move(
|
||||||
shared.lookupAppdataFolder() + 'messages.dat', 'messages.dat')
|
shared.lookupAppdataFolder() + 'messages.dat', shared.lookupExeFolder() + 'messages.dat')
|
||||||
self.conn = sqlite3.connect('messages.dat')
|
self.conn = sqlite3.connect(shared.lookupExeFolder() + 'messages.dat')
|
||||||
self.conn.text_factory = str
|
self.conn.text_factory = str
|
||||||
self.cur = self.conn.cursor()
|
self.cur = self.conn.cursor()
|
||||||
elif item == 'movemessagstoappdata':
|
elif item == 'movemessagstoappdata':
|
||||||
|
@ -520,8 +520,8 @@ class sqlThread(threading.Thread):
|
||||||
return
|
return
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
shutil.move(
|
shutil.move(
|
||||||
'messages.dat', shared.lookupAppdataFolder() + 'messages.dat')
|
shared.lookupExeFolder() + 'messages.dat', shared.lookupAppdataFolder() + 'messages.dat')
|
||||||
self.conn = sqlite3.connect(shared.appdata + 'messages.dat')
|
self.conn = sqlite3.connect(shared.lookupAppdataFolder() + 'messages.dat')
|
||||||
self.conn.text_factory = str
|
self.conn.text_factory = str
|
||||||
self.cur = self.conn.cursor()
|
self.cur = self.conn.cursor()
|
||||||
elif item == 'deleteandvacuume':
|
elif item == 'deleteandvacuume':
|
||||||
|
|
|
@ -35,12 +35,12 @@ def loadConfig():
|
||||||
needToCreateKeysFile = True
|
needToCreateKeysFile = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
shared.config.read('keys.dat')
|
shared.config.read(shared.lookupExeFolder() + 'keys.dat'))
|
||||||
try:
|
try:
|
||||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||||
print 'Loading config files from same directory as program.'
|
print 'Loading config files from same directory as program.'
|
||||||
needToCreateKeysFile = False
|
needToCreateKeysFile = False
|
||||||
shared.appdata = ''
|
shared.appdata = shared.lookupExeFolder()
|
||||||
except:
|
except:
|
||||||
# Could not load the keys.dat file in the program directory. Perhaps it
|
# Could not load the keys.dat file in the program directory. Perhaps it
|
||||||
# is in the appdata directory.
|
# is in the appdata directory.
|
||||||
|
|
|
@ -198,6 +198,15 @@ def assembleErrorMessage(fatal=0, banTime=0, inventoryVector='', errorText=''):
|
||||||
payload += errorText
|
payload += errorText
|
||||||
return CreatePacket('error', payload)
|
return CreatePacket('error', payload)
|
||||||
|
|
||||||
|
def lookupExeFolder():
|
||||||
|
if frozen:
|
||||||
|
exeFolder = os.path.join(os.path.dirname(sys.executable), '/')
|
||||||
|
elif __file__:
|
||||||
|
exeFolder = os.path.join(os.path.dirname(__file__), '/')
|
||||||
|
else:
|
||||||
|
exeFolder = ''
|
||||||
|
return exeFolder
|
||||||
|
|
||||||
def lookupAppdataFolder():
|
def lookupAppdataFolder():
|
||||||
APPNAME = "PyBitmessage"
|
APPNAME = "PyBitmessage"
|
||||||
if "BITMESSAGE_HOME" in environ:
|
if "BITMESSAGE_HOME" in environ:
|
||||||
|
|
Reference in New Issue
Block a user