Set server and port from command line
This commit is contained in:
parent
a05cbb858c
commit
836ec6c74d
2 changed files with 29 additions and 13 deletions
|
@ -28,6 +28,7 @@ CHANGELOG
|
||||||
* Advanced Mode: Alter IRC user mode - Kiooeht [evacipatedBox]
|
* Advanced Mode: Alter IRC user mode - Kiooeht [evacipatedBox]
|
||||||
* Logviewer chum search - Kiooeht [evacipatedBox]
|
* Logviewer chum search - Kiooeht [evacipatedBox]
|
||||||
* Logviewer log search - Kiooeht [evacipatedBox]
|
* Logviewer log search - Kiooeht [evacipatedBox]
|
||||||
|
* Set server and port from command line - Kiooeht [evacipated]
|
||||||
* Bug fixes
|
* Bug fixes
|
||||||
* Logviewer updates - Kiooeht [evacipatedBox]
|
* Logviewer updates - Kiooeht [evacipatedBox]
|
||||||
* Memo scrollbar thing - Kiooeht [evacipatedBox]
|
* Memo scrollbar thing - Kiooeht [evacipatedBox]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# pesterchum
|
# pesterchum
|
||||||
import logging
|
import logging
|
||||||
import os, sys
|
import os, sys, getopt
|
||||||
import os.path
|
import os.path
|
||||||
from datetime import *
|
from datetime import *
|
||||||
from string import Template
|
from string import Template
|
||||||
|
@ -13,7 +13,6 @@ import platform
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
import pygame
|
import pygame
|
||||||
from time import strftime
|
from time import strftime
|
||||||
import getopt
|
|
||||||
|
|
||||||
from menus import PesterChooseQuirks, PesterChooseTheme, \
|
from menus import PesterChooseQuirks, PesterChooseTheme, \
|
||||||
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
|
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
|
||||||
|
@ -265,7 +264,8 @@ class pesterTheme(dict):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class userConfig(object):
|
class userConfig(object):
|
||||||
def __init__(self):
|
def __init__(self, parent):
|
||||||
|
self.parent = parent
|
||||||
if sys.platform != "darwin":
|
if sys.platform != "darwin":
|
||||||
self.filename = "pesterchum.js"
|
self.filename = "pesterchum.js"
|
||||||
else:
|
else:
|
||||||
|
@ -426,8 +426,12 @@ class userConfig(object):
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
def server(self):
|
def server(self):
|
||||||
|
if hasattr(self.parent, 'serverOverride'):
|
||||||
|
return self.parent.serverOverride
|
||||||
return self.config.get('server', 'irc.mindfang.org')
|
return self.config.get('server', 'irc.mindfang.org')
|
||||||
def port(self):
|
def port(self):
|
||||||
|
if hasattr(self.parent, 'portOverride'):
|
||||||
|
return self.parent.portOverride
|
||||||
return self.config.get('port', '6667')
|
return self.config.get('port', '6667')
|
||||||
def soundOn(self):
|
def soundOn(self):
|
||||||
if not self.config.has_key('soundon'):
|
if not self.config.has_key('soundon'):
|
||||||
|
@ -1325,7 +1329,7 @@ class MovingWindow(QtGui.QFrame):
|
||||||
|
|
||||||
|
|
||||||
class PesterWindow(MovingWindow):
|
class PesterWindow(MovingWindow):
|
||||||
def __init__(self, parent=None, advanced=False):
|
def __init__(self, options, parent=None):
|
||||||
MovingWindow.__init__(self, parent,
|
MovingWindow.__init__(self, parent,
|
||||||
(QtCore.Qt.CustomizeWindowHint |
|
(QtCore.Qt.CustomizeWindowHint |
|
||||||
QtCore.Qt.FramelessWindowHint))
|
QtCore.Qt.FramelessWindowHint))
|
||||||
|
@ -1333,11 +1337,17 @@ class PesterWindow(MovingWindow):
|
||||||
self.memos = CaseInsensitiveDict()
|
self.memos = CaseInsensitiveDict()
|
||||||
self.tabconvo = None
|
self.tabconvo = None
|
||||||
self.tabmemo = None
|
self.tabmemo = None
|
||||||
self.advanced = advanced
|
if "advanced" in options:
|
||||||
|
self.advanced = options["advanced"]
|
||||||
|
else: self.advanced = False
|
||||||
|
if "server" in options:
|
||||||
|
self.serverOverride = options["server"]
|
||||||
|
if "port" in options:
|
||||||
|
self.portOverride = options["port"]
|
||||||
|
|
||||||
self.setAutoFillBackground(True)
|
self.setAutoFillBackground(True)
|
||||||
self.setObjectName("main")
|
self.setObjectName("main")
|
||||||
self.config = userConfig()
|
self.config = userConfig(self)
|
||||||
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()
|
||||||
|
@ -2655,7 +2665,7 @@ class MainProgram(QtCore.QObject):
|
||||||
self.app = QtGui.QApplication(sys.argv)
|
self.app = QtGui.QApplication(sys.argv)
|
||||||
self.app.setApplicationName("Pesterchum 3.14")
|
self.app.setApplicationName("Pesterchum 3.14")
|
||||||
|
|
||||||
self.oppts(sys.argv[1:])
|
options = self.oppts(sys.argv[1:])
|
||||||
|
|
||||||
if pygame.mixer:
|
if pygame.mixer:
|
||||||
# we could set the frequency higher but i love how cheesy it sounds
|
# we could set the frequency higher but i love how cheesy it sounds
|
||||||
|
@ -2665,7 +2675,7 @@ class MainProgram(QtCore.QObject):
|
||||||
print "Warning: No sound! %s" % (e)
|
print "Warning: No sound! %s" % (e)
|
||||||
else:
|
else:
|
||||||
print "Warning: No sound!"
|
print "Warning: No sound!"
|
||||||
self.widget = PesterWindow(advanced=self.advanced)
|
self.widget = PesterWindow(options)
|
||||||
self.widget.show()
|
self.widget.show()
|
||||||
|
|
||||||
self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), self.widget, self.app)
|
self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), self.widget, self.app)
|
||||||
|
@ -2865,14 +2875,19 @@ class MainProgram(QtCore.QObject):
|
||||||
self.showLoading(self.widget, "F41L3D: %s" % stop)
|
self.showLoading(self.widget, "F41L3D: %s" % stop)
|
||||||
|
|
||||||
def oppts(self, argv):
|
def oppts(self, argv):
|
||||||
self.advanced = False
|
options = {}
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, "", ["advanced"])
|
opts, args = getopt.getopt(argv, "s:p:", ["server=", "port=", "advanced"])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
return
|
return options
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt in ("--advanced"):
|
if opt in ("-s", "--server"):
|
||||||
self.advanced = True
|
options["server"] = arg
|
||||||
|
elif opt in ("-p", "--port"):
|
||||||
|
options["port"] = arg
|
||||||
|
elif opt in ("--advanced"):
|
||||||
|
options["advanced"] = True
|
||||||
|
return options
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.irc.start()
|
self.irc.start()
|
||||||
|
|
Loading…
Reference in a new issue