Missing defaultprofile error fix attempt.
This commit is contained in:
parent
5c987ae4b0
commit
0d36d73eee
2 changed files with 46 additions and 7 deletions
|
@ -1063,12 +1063,21 @@ class PesterWindow(MovingWindow):
|
||||||
self.setAutoFillBackground(True)
|
self.setAutoFillBackground(True)
|
||||||
self.setObjectName("main")
|
self.setObjectName("main")
|
||||||
self.config = userConfig(self)
|
self.config = userConfig(self)
|
||||||
|
# Trying to fix:
|
||||||
|
# IOError: [Errno 2]
|
||||||
|
# No such file or directory:
|
||||||
|
# u'XXX\\AppData\\Local\\pesterchum/profiles/XXX.js'
|
||||||
|
# Part 1 :(
|
||||||
|
try:
|
||||||
if self.config.defaultprofile():
|
if self.config.defaultprofile():
|
||||||
self.userprofile = userProfile(self.config.defaultprofile())
|
self.userprofile = userProfile(self.config.defaultprofile())
|
||||||
self.theme = self.userprofile.getTheme()
|
self.theme = self.userprofile.getTheme()
|
||||||
else:
|
else:
|
||||||
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
|
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
|
||||||
self.theme = self.userprofile.getTheme()
|
self.theme = self.userprofile.getTheme()
|
||||||
|
except:
|
||||||
|
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
|
||||||
|
self.theme = self.userprofile.getTheme()
|
||||||
self.modes = ""
|
self.modes = ""
|
||||||
|
|
||||||
self.sound_type = None
|
self.sound_type = None
|
||||||
|
|
30
profile.py
30
profile.py
|
@ -99,8 +99,16 @@ class userConfig(object):
|
||||||
self.filename = _datadir+"pesterchum.js"
|
self.filename = _datadir+"pesterchum.js"
|
||||||
with open(self.filename) as fp:
|
with open(self.filename) as fp:
|
||||||
self.config = json.load(fp)
|
self.config = json.load(fp)
|
||||||
|
# Trying to fix:
|
||||||
|
# IOError: [Errno 2]
|
||||||
|
# No such file or directory:
|
||||||
|
# u'XXX\\AppData\\Local\\pesterchum/profiles/XXX.js'
|
||||||
|
# Part 2 :(
|
||||||
if self.config.has_key("defaultprofile"):
|
if self.config.has_key("defaultprofile"):
|
||||||
|
try:
|
||||||
self.userprofile = userProfile(self.config["defaultprofile"])
|
self.userprofile = userProfile(self.config["defaultprofile"])
|
||||||
|
except:
|
||||||
|
self.userprofile = None
|
||||||
else:
|
else:
|
||||||
self.userprofile = None
|
self.userprofile = None
|
||||||
|
|
||||||
|
@ -364,8 +372,30 @@ class userProfile(object):
|
||||||
self.mentions = []
|
self.mentions = []
|
||||||
self.autojoins = []
|
self.autojoins = []
|
||||||
else:
|
else:
|
||||||
|
# Trying to fix:
|
||||||
|
# IOError: [Errno 2]
|
||||||
|
# No such file or directory:
|
||||||
|
# u'XXX\\AppData\\Local\\pesterchum/profiles/XXX.js'
|
||||||
|
# Part 3 :(
|
||||||
|
try:
|
||||||
with open("%s/%s.js" % (self.profiledir, user)) as fp:
|
with open("%s/%s.js" % (self.profiledir, user)) as fp:
|
||||||
self.userprofile = json.load(fp)
|
self.userprofile = json.load(fp)
|
||||||
|
except:
|
||||||
|
|
||||||
|
msgBox = QtGui.QMessageBox()
|
||||||
|
msgBox.setIcon(QtGui.QMessageBox.Information)
|
||||||
|
msgBox.setWindowTitle(":(")
|
||||||
|
self.filename = _datadir+"pesterchum.js"
|
||||||
|
msgBox.setText("Failed to open \"" + \
|
||||||
|
("%s/%s.js" % (self.profiledir, user)) + \
|
||||||
|
"\n You should switch to a different profile and set it as the default.")
|
||||||
|
#"\" if pesterchum acts oddly you might want to try backing up and then deleting \"" + \
|
||||||
|
#_datadir+"pesterchum.js" + \
|
||||||
|
#"\"")
|
||||||
|
msgBox.exec_()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.theme = pesterTheme(self.userprofile["theme"])
|
self.theme = pesterTheme(self.userprofile["theme"])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in a new issue