Thread: [Pymoul-svn] SF.net SVN: pymoul: [151] pymoul/trunk/src/moul (Page 3)
Status: Alpha
Brought to you by:
tiran
|
From: <ti...@us...> - 2007-02-06 20:31:15
|
Revision: 151
http://pymoul.svn.sourceforge.net/pymoul/?rev=151&view=rev
Author: tiran
Date: 2007-02-06 12:31:12 -0800 (Tue, 06 Feb 2007)
Log Message:
-----------
Fix for chatlog directory doesn't exist
Modified Paths:
--------------
pymoul/trunk/src/moul/file/chatlog.py
pymoul/trunk/src/moul/qt/i18n/__init__.py
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-02-06 17:51:25 UTC (rev 150)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-02-06 20:31:12 UTC (rev 151)
@@ -90,14 +90,20 @@
self.clear()
def clear(self):
+ """Clear results and check the existence of directories
+
+ @return: state of directories, True if everything is ok
+ @rtype: bool
"""
- """
self._logs = []
if not os.path.isdir(self._srcdir):
LOG.warning("%s is not a directory" % self._srcdir)
+ return False
if not os.path.isdir(self._destdir):
LOG.info("Creating chatlog directory %s" % self._destdir)
os.mkdir(destdir)
+ return False
+ return True
def findLogs(self):
"""Find log files in self._srcdir
@@ -105,7 +111,8 @@
Also calls and stores _findCreated(), modtime() and _makeFile()
for the file.
"""
- self.clear()
+ if not self.clear():
+ return
for file in os.listdir(self._srcdir):
if not fnmatch(file.lower(), self._pat):
continue
Modified: pymoul/trunk/src/moul/qt/i18n/__init__.py
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/__init__.py 2007-02-06 17:51:25 UTC (rev 150)
+++ pymoul/trunk/src/moul/qt/i18n/__init__.py 2007-02-06 20:31:12 UTC (rev 151)
@@ -56,7 +56,7 @@
@rtype: str or None
"""
global TRANSLATIONS
- if True: #__FROZEN__:
+ if __FROZEN__:
basedir = os.path.dirname(os.path.abspath(sys.argv[0]))
#basedir = sys.prefix
qm = os.path.join(basedir, 'i18n', '%s.qm' % name)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-07 11:31:54
|
Revision: 153
http://pymoul.svn.sourceforge.net/pymoul/?rev=153&view=rev
Author: tiran
Date: 2007-02-07 03:31:49 -0800 (Wed, 07 Feb 2007)
Log Message:
-----------
Fixed typo in file.chatlog
Added PBML parser to localization
Modified Paths:
--------------
pymoul/trunk/src/moul/file/chatlog.py
pymoul/trunk/src/moul/file/localization.py
pymoul/trunk/src/moul/qt/mainwindow.py
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-02-06 20:35:26 UTC (rev 152)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-02-07 11:31:49 UTC (rev 153)
@@ -131,7 +131,7 @@
'modtime' : mtime,
'created' : created,
'newname' : newname,
- 'newpath' : os.path.join(self._destdirt, newname),
+ 'newpath' : os.path.join(self._destdir, newname),
}
self._logs.append(details)
Modified: pymoul/trunk/src/moul/file/localization.py
===================================================================
--- pymoul/trunk/src/moul/file/localization.py 2007-02-06 20:35:26 UTC (rev 152)
+++ pymoul/trunk/src/moul/file/localization.py 2007-02-07 11:31:49 UTC (rev 153)
@@ -20,9 +20,11 @@
from __future__ import with_statement
import glob
import os
+from sgmllib import SGMLParser
from xml.sax import ContentHandler
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces
+from xml.sax.saxutils import unescape
from moul.log import getLogger
@@ -197,8 +199,42 @@
def __str__(self):
return self.content
+class PBMLParser(SGMLParser):
+ """Plasma Book Markup Language parser
+
+ Handles the PBML language used to describe books in Uru.
+ """
+ def __init__(self):
+ self.pbml_content = []
+ return SGMLParser.__init__(self)
+
+ def handle_data(self, data):
+ """Handle data outside tags
+ """
+ self.pbml_content.append(data)
+
+ def getPBML(self):
+ """Get PBML data and close parser
+
+ @return: pbml data w/o tags
+ @rtype: unicode
+ """
+ self.close()
+ return u''.join(self.pbml_content)
+
+ def feedEscaped(self, data):
+ """Feed escaped data as read from loc files
+
+ @param data: data to parse
+ @type data: str or unicode
+ """
+ self.feed(unescape(data))
+
class MoulLocHandler(ContentHandler):
- """Content handler for Myst Online Uru Live locatization"""
+ """Content handler for Myst Online Uru Live localization
+
+ Reads and parsed .loc files which contain MOUL's i18n text.
+ """
def __init__(self, fname=''):
self._fname = fname
@@ -246,11 +282,13 @@
"""</translation> handler
"""
content = u''.join(self._content)
+ pbml = PBMLParser()
+ pbml.feedEscaped(content)
tl = Translation(age = self._age,
set = self._set,
element = self._element,
language = self._language,
- content = content,
+ content = pbml.getPBML(),
fname = self._fname)
self.translations.append(tl)
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-06 20:35:26 UTC (rev 152)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-07 11:31:49 UTC (rev 153)
@@ -262,6 +262,7 @@
def on_pb_log_archive_clicked(self):
"""
"""
+ self.emit(SIGNAL("chatlogsUpdated()"))
chatmover = self.urupersonaldir.chatmover
logzipper = self.urupersonaldir.logzipper
if chatmover.findLogs():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-07 13:28:12
|
Revision: 154
http://pymoul.svn.sourceforge.net/pymoul/?rev=154&view=rev
Author: tiran
Date: 2007-02-07 05:28:12 -0800 (Wed, 07 Feb 2007)
Log Message:
-----------
Removed clear call from Threadlet.run()
Implemented first version of chat log browser
Modified Paths:
--------------
pymoul/trunk/src/moul/file/chatlog.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/threadlet.py
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-02-07 11:31:49 UTC (rev 153)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-02-07 13:28:12 UTC (rev 154)
@@ -204,40 +204,47 @@
Lists all chat logs in the directory
"""
- def __init__(self, logdir):
- self._logdir = logdir
- self._logfiles = [] # list of ChatlogViews
+ def __init__(self, archivedir):
+ self._archivedir = archivedir
+ self._chatlogs = [] # list of ChatlogViews
+ LOG.debug("Chatlogs DV in %s" % archivedir)
self.refresh()
def refresh(self):
"""Refresh list
"""
# TODO: inefficient, compare list with directory content
- if not os.path.isdir(self._logdir):
- LOG.warning("%s is not a directory" % logdir)
- return
- self._logfiles[:] = []
+ if not os.path.isdir(self._archivedir):
+ LOG.warning("%s is not a directory" % self._archivedir)
+ return
+ self._chatlogs[:] = []
self._findChatlogs()
def _findChatlogs(self):
"""Find chat logs in logdir directory
"""
- for name in os.listdir(self._logdir):
- fname = os.path.join(self._logdir, name)
+ for name in os.listdir(self._archivedir):
+ fname = os.path.join(self._archivedir, name)
if not os.path.isfile(fname):
continue
chatlog = ChatlogView(fname)
if chatlog.date is not None:
- self._logfiles.append(chatlog)
- self._logfiles.sort(key=lambda element:(element.date, element.name))
+ self._chatlogs.append(chatlog)
+ self._chatlogs.sort(key=lambda element:element.name)
def __len__(self):
"""len() support
"""
- return len(self._logfiles)
+ return len(self._chatlogs)
def __iter__(self):
- return iter(self._logfiles)
+ return iter(self._chatlogs)
+
+ def __contains__(self, other):
+ return other in self._chatlogs
+
+ def __getitem__(self, idx):
+ return self._chatlogs[idx]
class ChatlogView(object):
"""A view of a single chat log file
@@ -271,9 +278,21 @@
if not mo:
# urks
return None
- d = mo.groupdict()
+ d = {}
+ for key, value in mo.groupdict().items():
+ d[key] = int(value)
self._date = d
return d
+
+ @property
+ def humanname(self):
+ """Human readable name
+ """
+ d = self.date
+ if not d:
+ return self.name
+ return "Chatlog %02i:%02i - %02i:%02i %02i-%02i-%02i" % (
+ d['ch'], d['cm'], d['sh'], d['sm'], d['Y'], d['M'], d['D'])
def open(self):
"""Open fhe file
@@ -281,6 +300,7 @@
if not self._opened:
self._fd = open(self._fname, 'r')
self._opened = True
+ self._fd.seek(0)
def close(self):
"""Close the file
@@ -298,4 +318,4 @@
@rtype: str
"""
self.open()
- self._fd.read()
+ return self._fd.read()
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-07 11:31:49 UTC (rev 153)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-07 13:28:12 UTC (rev 154)
@@ -46,6 +46,7 @@
from moul.qt.wdysini import IniFileContainer
from moul.qt.simpleprogressbar import SimpleProgressbar
from moul.qt.threadlet import YieldingThreadlet
+from moul.qt.threadlet import Threadlet
from moul.qt.ui.mainwindow import Ui_MainWindow
from moul.qt import utils as qtutils
@@ -87,6 +88,7 @@
self._ping_init()
self._systray_init()
self._about_init()
+ self._chatlog_init()
self.qcLocalization = LocalizationContainer(self)
self.qcIniFile = IniFileContainer(self)
@@ -208,7 +210,45 @@
# ************************************************************************
# tasks
+ def _chatlog_init(self):
+ self._chatlog_threadlet = Threadlet(self)
+ self.connect(self, SIGNAL("chatlogsUpdated()"),
+ self._chatlog_threadlet.start)
+ self.connect(self._chatlog_threadlet, SIGNAL("finished()"),
+ self.on_chatlogview_refresh)
+ # detach and fire
+ self._chatlog_threadlet.detach(self.on_chatlogs_updated)
+
@pyqtSignature("")
+ def on_chatlogs_updated(self):
+ """
+ Called as detached method inside a threadlet
+ """
+ self.urupersonaldir.chatview.refresh()
+
+ @pyqtSignature("")
+ def on_chatlogview_refresh(self):
+ """
+ Called when the chatlet threadlet has finished
+ """
+ self.cb_chatlog.clear()
+ lst = [chatview.humanname
+ for chatview in self.urupersonaldir.chatview]
+ lst.insert(0, "<choose>")
+ self.cb_chatlog.addItems(QtCore.QStringList(lst))
+
+ @pyqtSignature("int")
+ def on_cb_chatlog_currentIndexChanged(self, idx):
+ """
+ """
+ self.tb_chatlog_view.clear()
+ if idx < 1:
+ # chooser or -1
+ return
+ chatview = self.urupersonaldir.chatview[idx-1]
+ self.tb_chatlog_view.setPlainText(chatview.view())
+
+ @pyqtSignature("")
def on_pb_kiimage_repair_clicked(self):
"""
Clicked repair button
@@ -262,7 +302,6 @@
def on_pb_log_archive_clicked(self):
"""
"""
- self.emit(SIGNAL("chatlogsUpdated()"))
chatmover = self.urupersonaldir.chatmover
logzipper = self.urupersonaldir.logzipper
if chatmover.findLogs():
@@ -273,12 +312,16 @@
len(chatmover))
)
mb.exec_()
+ self.emit(SIGNAL("chatlogsUpdated()"))
else:
mb = qtutils.infoMB(self,
self.trUtf8("Chatlog archive"),
self.trUtf8("No chatlog(s) to archive")
)
mb.exec_()
+ # also emit the signal here so the button reacts as a refresh
+ # button, too
+ self.emit(SIGNAL("chatlogsUpdated()"))
#mb = qtutils.notImplementedMB(self)
#mb.exec_()
Modified: pymoul/trunk/src/moul/qt/threadlet.py
===================================================================
--- pymoul/trunk/src/moul/qt/threadlet.py 2007-02-07 11:31:49 UTC (rev 153)
+++ pymoul/trunk/src/moul/qt/threadlet.py 2007-02-07 13:28:12 UTC (rev 154)
@@ -79,6 +79,9 @@
self._args = None
self._kwargs = None
+ def __del__(self):
+ self.clear()
+
def detach(self, obj, *args, **kwargs):
"""
Detach a function call
@@ -89,8 +92,8 @@
"""
self.mutex.lock()
self._obj = obj
- self._args = args
- self._kwargs = kwargs
+ self._args = args or ()
+ self._kwargs = kwargs or {}
self.mutex.unlock()
if not self.isRunning():
self.start()
@@ -107,7 +110,6 @@
self.mutex.lock()
result = self._obj(*self._args, **self._kwargs)
self.emit(SIGNAL("done(result)"), result)
- self.clear()
self.mutex.unlock()
class YieldingThreadlet(Threadlet):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-12 13:36:27
|
Revision: 159
http://pymoul.svn.sourceforge.net/pymoul/?rev=159&view=rev
Author: tiran
Date: 2007-02-12 05:36:09 -0800 (Mon, 12 Feb 2007)
Log Message:
-----------
Added mac pathes
First work on DNI time module
Modified Paths:
--------------
pymoul/trunk/src/moul/log.py
pymoul/trunk/src/moul/osdependent/darwin/__init__.py
pymoul/trunk/src/moul/osdependent/linux/__init__.py
pymoul/trunk/src/moul/time/__init__.py
pymoul/trunk/src/moul/time/cavern.py
pymoul/trunk/src/moul/time/dni.py
pymoul/trunk/src/moul/time/tests/test_cavern.py
Modified: pymoul/trunk/src/moul/log.py
===================================================================
--- pymoul/trunk/src/moul/log.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/log.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -117,7 +117,7 @@
shdlr = logging.StreamHandler(sys.stderr)
shdlr.setFormatter(format)
root.addHandler(shdlr)
- _systemInfo()
+ #_systemInfo()
else:
_installMemoryHdlr()
_systemInfo()
Modified: pymoul/trunk/src/moul/osdependent/darwin/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/darwin/__init__.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/osdependent/darwin/__init__.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -30,9 +30,17 @@
LOG = getLogger('moul.darwin')
LOG.critical('Darwin/Mac support is not tested')
-MOUL_DIR = "Uru Live"
-EXEC_NAME = "UruLauncher"
-HOME = os.environ['HOME']
+HOME = os.path.expanduser('~')
+MOUL_DIR = "Library/Preferences/UruLive Preferences/p_drive/My Documents/Uru Live"
+APP_PATH = "Uru Live.app/Contents/Resources/Game.app/Contents/Resources/transgaming/c_drive/Program Files/Uru Live/"
+APP_NAME = "Uru Live.app"
+EXEC_NAME = "???" # XXX
+UPDATER = "Uru Live.app/Contents/Resources/Game.app/Contents/Resources/URU Live Updater.app/Contents/MacOS/URU Live Updater"
+LOCATIONS = [
+ "/Applications",
+ "%s/Applications" % HOME,
+ ]
+PYMOUL_DIR = "Library/Preferences/pyMoul"
def getMoulUserDataDir():
"""Get path of MOUL data directory
@@ -45,7 +53,7 @@
def getPyMoulDataDir():
"""Get path to the pyMoul ini directory
"""
- inidir= os.path.join(HOME, '.pymoul')
+ inidir= os.path.join(HOME, PYMOUL_DIR)
return inidir
def startMoul(installdir, *args, **kwargs):
Modified: pymoul/trunk/src/moul/osdependent/linux/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/linux/__init__.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/osdependent/linux/__init__.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -31,10 +31,10 @@
LOG = getLogger('moul.linux')
LOG.critical('Linux support is not tested')
+HOME = os.path.expanduser('~')
MOUL_DIR = ".urulive"
INI_FILE = ('pyMoul', 'pymoul.ini')
EXEC_NAME = "UruLauncher"
-HOME = os.environ['HOME']
PROCESSES = ('urulauncher', 'uruexplorer')
LOCATIONS = [
"%s/dev/pymoul/MystOnline" % HOME,
Modified: pymoul/trunk/src/moul/time/__init__.py
===================================================================
--- pymoul/trunk/src/moul/time/__init__.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/time/__init__.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -20,3 +20,9 @@
__author__ = "Christian Heimes"
__version__ = "$Id$"
__revision__ = "$Revision$"
+
+from moul.osdependent import __FROZEN__
+# pytz is an egg
+if not __FROZEN__:
+ import pkg_resources
+ pkg_resources.require("pytz>=2006p")
Modified: pymoul/trunk/src/moul/time/cavern.py
===================================================================
--- pymoul/trunk/src/moul/time/cavern.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/time/cavern.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -24,17 +24,15 @@
__all__ = ['CavernTime']
from datetime import datetime
-
-from moul.osdependent import __FROZEN__
-# pytz is an egg
-if not __FROZEN__:
- import pkg_resources
- pkg_resources.require("pytz>=2006p")
-
from pytz import all_timezones
from pytz import timezone
from pytz import utc as UTC
+from moul.time.utils import td2sec
+from moul.time.utils import diffTD
+from moul.time.utils import utcnow
+from moul.time.utils import normalizeTZ
+
## not used in the current version
#SUPPORTED_TZ = ('America', 'Canada', 'Etc', 'Europe', 'US')
#ADDITIONAL_TZ = ('GMT', 'UTC')
@@ -73,42 +71,6 @@
PACIFIC_TZ_NAME = ('US/Pacific', 'PST', 'PDT') # PST / PDT
PACIFIC_TZ = timezone(PACIFIC_TZ_NAME[0])
-def diffTD(td1, td2):
- """Difference of two time delta objects -> int
-
- >>> from datetime import timedelta
- >>> type(diffTD(timedelta(0, 3600), timedelta(0, -3600)))
- <type 'int'>
- >>> diffTD(timedelta(0, 3600), timedelta(0, -3600))
- 7200
- >>> diffTD(timedelta(0, 3600), timedelta(0, 3600))
- 0
- >>> diffTD(timedelta(0, -3600), timedelta(0, -3600))
- 0
- >>> diffTD(timedelta(0, -7200), timedelta(0, -3600))
- -3600
- >>> diffTD(timedelta(0, -3600), timedelta(0, -7200))
- 3600
- >>> diffTD(timedelta(0, 3600, 1), timedelta(0, -3600))
- Traceback (most recent call last):
- ...
- ValueError: Can't handle microseconds
- """
- if td1.microseconds or td2.microseconds:
- raise ValueError("Can't handle microseconds")
- return (td1.seconds + 86400 * td1.days) - (td2.seconds + 86400 * td2.days)
-
-def td2int(td):
- """timedelta to int
-
- >>> from datetime import timedelta
- >>> td2int(timedelta(0, 3600))
- 3600
- >>> td2int(timedelta(0, -3600))
- -3600
- """
- return td.seconds + 86400 * td.days
-
class CavernTime(object):
"""Cavern time calculator
@@ -167,41 +129,27 @@
_cavern_name = CAVERN_TZ_NAME
_pacific = PACIFIC_TZ
_pacific_name = PACIFIC_TZ_NAME
-
- @staticmethod
- def _utcnow():
- """Get current time in UTC
- """
- return UTC.localize(datetime.utcnow())
- @staticmethod
- def _normalize(tz, utc_dt=None):
- """Normalize a datetime object with UTC tz using another tz
- """
- if utc_dt is None:
- utc_dt = self._utcnow()
- return tz.normalize(utc_dt.astimezone(tz))
-
def __call__(self):
- now = self._utcnow()
+ now = utcnow()
result = {}
for id, tz in (('cavern', self._cavern), ('pacific', self._pacific)):
- result[id] = self._normalize(tz, now)
+ result[id] = normalizeTZ(tz, now)
return result
def info(self):
- now = self._utcnow()
+ now = utcnow()
result = {}
for id, tz in (('cavern', self._cavern), ('pacific', self._pacific)):
info = result.setdefault(id, {})
- utcoffset = td2int(tz.utcoffset(now))
+ utcoffset = td2sec(tz.utcoffset(now))
signum = utcoffset < 0 and '-' or '+'
info['tz'] = tz
info['utcoffset'] = signum,int(utcoffset/3600), float((utcoffset%3600)/3600.0)
- info['datetime'] = self._normalize(tz, now)
+ info['datetime'] = normalizeTZ(tz, now)
info['name'] = str(tz)
info['id'] = tz._tzname
- info['dst'] = td2int(tz.dst(now))
+ info['dst'] = td2sec(tz.dst(now))
result['utc'] = {'datetime' : now}
return result
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -15,53 +15,94 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-"""pyMoul D'ni time tool
+"""pyMoul D'ni time tool
+
+Based on informations from http://www.dpwr.net/archive.php?showarticle=2193
+
+official sources say that:
+00:00:00:00, Leefo 1, 9654 DE = 10:35:18 UTC, April 21, 1998 CE
+>>> LEEFO_1_TABLE = [
+... datetime(1998, 4, 21, 10, 35, 18, 0, UTC),
+... datetime(1999, 4, 21, 16, 24, 3, 0, UTC),
+... datetime(2000, 4, 20, 22, 12, 48, 0, UTC),
+... datetime(2001, 4, 21, 4, 1, 33, 0, UTC),
+... datetime(2002, 4, 21, 9, 50, 18, 0, UTC),
+... datetime(2003, 4, 21, 15, 39, 3, 0, UTC),
+... ]
+
+>>> dni = DniTime()
+>>> dni.fromUTC(LEEFO_1_TABLE[1])
+>>> dni.get()
+(9655, 0, 0, 0, 0, 0, 0)
+
"""
__author__ = "Christian Heimes"
__version__ = "$Id$"
__revision__ = "$Revision$"
+from datetime import datetime
from operator import mul
+from pytz import utc as UTC
+import sys
+from moul.time.utils import td2sec
+from moul.time.utils import utcnow
-FARAH_1 = -7656 # hahrtee fahrah 1 starts at April 21st 7656 B.C
+
+FAHRAH_1 = -7656 # hahrtee fahrah 1 starts at April 21st 7656 B.C
+
+# name -> amount of smaller element, e.g. a hartee fahrah as 625 hahr
DNI_FACTORS = (
('hahrtee fahrah', 625),
- ('hahr', 10),
- ('vai-lee', 29),
- ('yahr', 5),
- ('gahr-tah-vo', 25),
- ('tah-vo', 25),
- ('gor-ahn', 25),
- ('pro-rahn', 1),
-)
+ ('hahr', 10), # year
+ ('vai-lee', 29), # month
+ ('yahr', 5), # day (~30h and 14min)
+ # bell - each yahr has 25 bells (~74 min)
+ ('gahr-tah-vo', 25), # ~6h 3min
+ ('tah-vo', 25), # ~14,5 min
+ ('gor-ahn', 25), # ~34,8 seconds
+ ('pro-rahn', None), # ~1.39 seconds
+ )
-VAILATEE = (
- ('Leefo', ( 4, 21), ( 5, 27)), # 1: April 21st to May 27th
- ('Leebro', ( 5, 28), ( 7, 3)), # 2: May 28th to July 3rd
- ('Leesahn', ( 7, 3), ( 8, 8)), # 3: July 3rd to August 8th
- ('Leetar', ( 8, 9), ( 9, 15)), # 4: August 9th and September 14th
- ('Leevot', ( 9, 14), (10, 20)), # 5: September 14th to October 20th
- ('Leevofo', (10, 21), (11, 26)), # 6: October 21st to November 26th
- ('Leevobro', (11, 26), ( 1, 1)), # 7: November 26th to January 1st
- ('Leevosahn', ( 1, 2), ( 2, 7)), # 8: January 2nd to February 7th
- ('Leevotar', ( 2, 7), ( 3, 15)), # 9: February 7th to March 15th
- ('Leenovoo', ( 3, 16), ( 4, 21)), # 10: March 16th to April 21st
-)
+# list of month names with approx. dates
+VAILEETEE = (
+ 'Leefo', # 1: April 21st to May 27th
+ 'Leebro', # 2: May 28th to July 3rd
+ 'Leesahn', # 3: July 3rd to August 8th
+ 'Leetar', # 4: August 9th and September 14th
+ 'Leevot', # 5: September 14th to October 20th
+ 'Leevofo', # 6: October 21st to November 26th
+ 'Leevobro', # 7: November 26th to January 1st
+ 'Leevosahn', # 8: January 2nd to February 7th
+ 'Leevotar', # 9: February 7th to March 15th
+ 'Leenovoo', # 10: March 16th to April 21st
+ )
-PRORAHN_PER_HAHR = reduce(mul,
- [float(factor) for name, factor in DNI_FACTORS[1:-1]])
+# 00:00:00:00, Leefo 1, 9654 DE
+BASE = datetime(1998, 4, 21, 10, 35, 18, 0, UTC)
+BASE_HAHR = 9654
+SECONDS_PER_HAHR = 31556925
+PRORAHN_PER_HAHR = 22656250
+FACTOR_SH = float(SECONDS_PER_HAHR) / float(PRORAHN_PER_HAHR)
+FACTOR_HS = float(PRORAHN_PER_HAHR) / float(SECONDS_PER_HAHR)
-# Official SI year 365.25 days = 31.557.600 seconds
-YEAR_SI = 31557600
-# Sidereal year: 365.256 363 051 days (365 d 6 h 9 min 9 s)
-# YEAR_SIDEREAL = (((((365 * 24) + 6 ) * 60 ) + 9 ) * 60 ) + 9
-YEAR = float(YEAR_SI)
+def valueCheck(typ, minv, maxv):
+ """Value and type checking decorator
+ """
+ def wrapper(func):
+ def checker(self, value):
+ if not isinstance(value, typ):
+ raise TypeError("%s <%s>" % (value, type(value)))
+ if value < minv or value > maxv:
+ raise ValueError("%s not in (%i, %i)" % (value, minv, maxv))
+ return func(self, value)
+ checker.__doc__ = func.__doc__
+ checker.__name__ = func.__name__
+ return checker
+ return wrapper
-FACTOR = YEAR / PRORAHN_PER_HAHR
-
class DniTime(object):
- """D'ni time handler
+ """D'ni time representation
The D'ni were using a complex calendar based on a pentovigesimal (25)
numbering system.
@@ -91,11 +132,97 @@
gorahn minute 36 seconds
prorahn second about 1.3929 seconds
"""
- _fahrah = None # millenium (625 years)
- _hahr = None # year (1 year)
- _vailee = None # month (10 per year)
- _yahr = None # day (29 per vailee)
- _gahrtahvo = None # section (about 6h, 3min)
- _tahvo = None # quarter (about 14,5min)
- _gorahn = None # minute (about 36 seconds)
- _prorahn = None # second (1,4 seconds)
+ def __init__(self, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
+ gorahn=0, prorahn=0):
+ self.set(hahr, vailee, yahr, gahrtahvo, tahvo, gorahn, prorahn)
+
+ def set(self, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
+ gorahn=0, prorahn=0):
+ self.hahr = hahr
+ self._prorahn = 0
+ self.vailee = vailee
+ self.yahr = yahr
+ self.gahrtahvo = gahrtahvo
+ self.tahvo = tahvo
+ self.gorahn = gorahn
+ self._addProrahn(prorahn)
+
+ def get(self):
+ return (self.hahr, self.vailee, self.yahr, self.gahrtahvo, self.tahvo,
+ self.gorahn, self.prorahn)
+
+ def fromUTC(self, utc_dt=None):
+ """Convert from UTC datetime
+ """
+ if utc_dt is None:
+ utc_dt = utcnow()
+ sec = td2sec(utc_dt - BASE)
+ prorahn = sec * FACTOR_HS
+ self.set(hahr=BASE_HAHR, prorahn=prorahn)
+
+ def toUTC(self):
+ """Convert to UTC datetime value
+ """
+ raise NotImplementedError
+
+ def _getHahr(self):
+ return self._hahr
+ @valueCheck(int, 0, sys.maxint)
+ def _setHahr(self, value):
+ self._hahr = value
+ hahr = property(_getHahr, _setHahr)
+
+ def _getVailee(self):
+ return self._prorahn // 2265625
+ @valueCheck(int, 0, 10)
+ def _setVailee(self, value):
+ self._addProrahn(value * 2265625)
+ vailee = property(_getVailee, _setVailee)
+
+ def getVaileeName(self):
+ return VAILEETEE[self.vailee]
+
+ def _getYahr(self):
+ return self._prorahn // 78125
+ @valueCheck(int, 0, 29)
+ def _setYahr(self, value):
+ self._addProrahn(value * 78125)
+ yahr = property(_getYahr, _setYahr)
+
+ def _getBell(self):
+ return self.gahrtahvo // 5
+ bell = property(_getBell)
+
+ def _getGahrtahvo(self):
+ return self._prorahn // 15625
+ @valueCheck(int, 0, 5)
+ def _setGahrtahvo(self, value):
+ self._addProrahn(value * 15625)
+ gahrtahvo = property(_getGahrtahvo, _setGahrtahvo)
+
+ def _getTahvo(self):
+ return self._prorahn // 625
+ @valueCheck(int, 0, 25)
+ def _setTahvo(self, value):
+ self._addProrahn(value * 625)
+ tahvo = property(_getTahvo, _setTahvo)
+
+ def _getGorahn(self):
+ return self._prorahn // 25
+ @valueCheck(int, 0, 25)
+ def _setGorahn(self, value):
+ self._addProrahn(value * 25)
+ gorahn = property(_getGorahn, _setGorahn)
+
+ def _getProrahn(self):
+ return self._prorahn % 25
+ @valueCheck(int, 0, 25)
+ def _setProrahn(self, value):
+ self._prorahn+= value
+ prorahn = property(_getProrahn, _setProrahn)
+
+ def _addProrahn(self, value):
+ self._prorahn += int(value)
+ addhahr = self._prorahn // PRORAHN_PER_HAHR
+ if addhahr:
+ self._hahr += addhahr
Modified: pymoul/trunk/src/moul/time/tests/test_cavern.py
===================================================================
--- pymoul/trunk/src/moul/time/tests/test_cavern.py 2007-02-10 16:01:28 UTC (rev 158)
+++ pymoul/trunk/src/moul/time/tests/test_cavern.py 2007-02-12 13:36:09 UTC (rev 159)
@@ -31,6 +31,7 @@
def test_suite():
return unittest.TestSuite((
DocTestSuite('moul.time.cavern'),
+ DocTestSuite('moul.time.utils'),
))
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-12 19:34:23
|
Revision: 162
http://pymoul.svn.sourceforge.net/pymoul/?rev=162&view=rev
Author: tiran
Date: 2007-02-12 11:34:10 -0800 (Mon, 12 Feb 2007)
Log Message:
-----------
Show D'ni time
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/time/dni.py
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-12 17:15:11 UTC (rev 161)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-12 19:34:10 UTC (rev 162)
@@ -42,6 +42,8 @@
from moul.server.ping import isSocketError
from moul.server.ping import fmtSocketError
from moul.time.cavern import CavernTime
+from moul.time.dni import DniTime
+from moul.time.dni import FACTOR_SP
from moul.qt.localization import LocalizationContainer
from moul.qt.wdysini import IniFileContainer
@@ -388,12 +390,21 @@
# create a timer to update the display every second
# TODO: change timer from every second to every minute
- self._timezone_timer = timer = QtCore.QTimer(self)
- timer.setInterval(1000) # 1 sec
+ self._timezone_timer = QtCore.QTimer(self)
+ self._timezone_timer.setInterval(1000) # 1 sec
# TODO: needs optimization? run only when timer tab is active
- self.connect(timer, SIGNAL('timeout()'), self.on_timezone_timer_timeout)
- timer.start()
+ self.connect(self._timezone_timer, SIGNAL('timeout()'),
+ self.on_timezone_timer_timeout)
+ self._timezone_timer.start()
+ self._dnitime = DniTime()
+ self.on_dnitimer_timeout()
+ self._dnitime_timer = QtCore.QTimer(self)
+ self._dnitime_timer.setInterval(FACTOR_SP*1000)
+ self.connect(self._dnitime_timer, SIGNAL('timeout()'),
+ self.on_dnitimer_timeout)
+ self._dnitime_timer.start()
+
def _timezone_update(self):
"""
Update datetime widgets
@@ -421,6 +432,15 @@
self.dt_cavern.setDateTime(ct['cavern'])
self.dt_pacific.setDateTime(ct['pacific'])
+ @pyqtSignature("")
+ @qtutils.skipLogging
+ def on_dnitimer_timeout(self):
+ """
+ SIGNAL: QTimer timeout
+ """
+ dni = self._dnitime.fromUTC() # set to now
+ self.le_dnitime.setText(str(self._dnitime)+", bell: %s" % self._dnitime.bell)
+
# ************************************************************************
# ping
def _ping_init(self):
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-12 17:15:11 UTC (rev 161)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-12 19:34:10 UTC (rev 162)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './src/moul/qt/ui/mainwindow.ui'
#
-# Created: Tue Feb 6 04:38:34 2007
+# Created: Mon Feb 12 20:15:18 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -117,7 +117,7 @@
self.gridlayout.addWidget(self.lb_log_remove,1,1,1,3)
self.groupBox_2 = QtGui.QGroupBox(self.tab_tasks)
- self.groupBox_2.setGeometry(QtCore.QRect(10,130,451,81))
+ self.groupBox_2.setGeometry(QtCore.QRect(10,120,451,81))
self.groupBox_2.setObjectName("groupBox_2")
self.layoutWidget1 = QtGui.QWidget(self.groupBox_2)
@@ -142,7 +142,7 @@
self.hboxlayout1.addItem(spacerItem3)
self.gb_caverntime = QtGui.QGroupBox(self.tab_tasks)
- self.gb_caverntime.setGeometry(QtCore.QRect(10,220,451,101))
+ self.gb_caverntime.setGeometry(QtCore.QRect(10,200,451,101))
self.gb_caverntime.setObjectName("gb_caverntime")
self.gridLayout = QtGui.QWidget(self.gb_caverntime)
@@ -201,6 +201,16 @@
spacerItem4 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
self.gridlayout1.addItem(spacerItem4,0,3,1,1)
+
+ self.gb_dnitime = QtGui.QGroupBox(self.tab_tasks)
+ self.gb_dnitime.setGeometry(QtCore.QRect(10,300,451,101))
+ self.gb_dnitime.setObjectName("gb_dnitime")
+
+ self.le_dnitime = QtGui.QLineEdit(self.gb_dnitime)
+ self.le_dnitime.setGeometry(QtCore.QRect(10,40,281,25))
+ self.le_dnitime.setEchoMode(QtGui.QLineEdit.Normal)
+ self.le_dnitime.setReadOnly(True)
+ self.le_dnitime.setObjectName("le_dnitime")
self.tabwidget.addTab(self.tab_tasks,"")
self.tab_settings = QtGui.QWidget()
@@ -927,6 +937,7 @@
self.lb_pacific_utc.setText(QtGui.QApplication.translate("MainWindow", "UTC -0", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("MainWindow", "Cavern time:", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Cyan time:", None, QtGui.QApplication.UnicodeUTF8))
+ self.gb_dnitime.setTitle(QtGui.QApplication.translate("MainWindow", "D\'ni time", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_tasks), QtGui.QApplication.translate("MainWindow", "Tasks", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_screenres.setTitle(QtGui.QApplication.translate("MainWindow", "Screen Resolution", None, QtGui.QApplication.UnicodeUTF8))
self.lb_screenres.setText(QtGui.QApplication.translate("MainWindow", "800x600 (4:3)", None, QtGui.QApplication.UnicodeUTF8))
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-12 17:15:11 UTC (rev 161)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-12 19:34:10 UTC (rev 162)
@@ -280,7 +280,7 @@
<property name="geometry" >
<rect>
<x>10</x>
- <y>130</y>
+ <y>120</y>
<width>451</width>
<height>81</height>
</rect>
@@ -347,7 +347,7 @@
<property name="geometry" >
<rect>
<x>10</x>
- <y>220</y>
+ <y>200</y>
<width>451</width>
<height>101</height>
</rect>
@@ -466,6 +466,35 @@
</layout>
</widget>
</widget>
+ <widget class="QGroupBox" name="gb_dnitime" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>300</y>
+ <width>451</width>
+ <height>101</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>D'ni time</string>
+ </property>
+ <widget class="QLineEdit" name="le_dnitime" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>281</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </widget>
</widget>
<widget class="QWidget" name="tab_settings" >
<attribute name="title" >
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-12 17:15:11 UTC (rev 161)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-12 19:34:10 UTC (rev 162)
@@ -18,10 +18,13 @@
"""pyMoul D'ni time tool
Based on informations from http://www.dpwr.net/archive.php?showarticle=2193
+Verified with http://home.earthlink.net/~seizuretown/myst/ccconverter.html
official sources say that:
00:00:00:00, Leefo 1, 9654 DE = 10:35:18 UTC, April 21, 1998 CE
+>>> from datetime import timedelta
+
>>> LEEFO_1_TABLE = [
... datetime(1998, 4, 21, 10, 35, 18, 0, tzinfo=UTC),
... datetime(1999, 4, 21, 16, 24, 3, 0, tzinfo=UTC),
@@ -118,8 +121,8 @@
BASE_YEAR = 1998
SECONDS_PER_HAHR = 31556925
PRORAHN_PER_HAHR = 22656250
-FACTOR_SP = float(SECONDS_PER_HAHR) / float(PRORAHN_PER_HAHR)
-FACTOR_PS = float(PRORAHN_PER_HAHR) / float(SECONDS_PER_HAHR)
+FACTOR_SP = float(SECONDS_PER_HAHR) / float(PRORAHN_PER_HAHR) # 1.39285737931
+FACTOR_PS = float(PRORAHN_PER_HAHR) / float(SECONDS_PER_HAHR) # 0.717948596069
def valueCheck(typ, minv, maxv):
"""Value and type checking decorator
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-13 03:16:08
|
Revision: 163
http://pymoul.svn.sourceforge.net/pymoul/?rev=163&view=rev
Author: tiran
Date: 2007-02-12 19:16:06 -0800 (Mon, 12 Feb 2007)
Log Message:
-----------
Renamed bell to pahrtove
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/time/dni.py
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-12 19:34:10 UTC (rev 162)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-13 03:16:06 UTC (rev 163)
@@ -439,7 +439,7 @@
SIGNAL: QTimer timeout
"""
dni = self._dnitime.fromUTC() # set to now
- self.le_dnitime.setText(str(self._dnitime)+", bell: %s" % self._dnitime.bell)
+ self.le_dnitime.setText(str(self._dnitime)+", bell: %s" % self._dnitime.pahrtovo)
# ************************************************************************
# ping
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-12 19:34:10 UTC (rev 162)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-13 03:16:06 UTC (rev 163)
@@ -23,6 +23,15 @@
official sources say that:
00:00:00:00, Leefo 1, 9654 DE = 10:35:18 UTC, April 21, 1998 CE
+D'ni New Year - Leefo 1, April 21
+First Feast of the Maker - Lenovoo 10, March 27 (Pre-earth celebration)
+The Common Library Opened - Leefo 12, May 5
+Second Feast of the Maker - Leebro 20, June 21 (Pre-earth celebration)
+The Day of Dancing - Leetar 21, September 3
+First Arrival of the Great King - Leevot 12, September 28
+Third Feast of the Maker - Leevofo 18, November 11 (Pre-earth celebration)
+Coronation of King Kerath - Leevofo 27, November 23
+
>>> from datetime import timedelta
>>> LEEFO_1_TABLE = [
@@ -74,7 +83,6 @@
__revision__ = "$Revision$"
from datetime import datetime
-from operator import mul
from pytz import utc as UTC
from time import mktime
import sys
@@ -91,7 +99,7 @@
('hahr', 10), # year
('vai-lee', 29), # month
('yahr', 5), # day (~30h and 14min)
- # bell - each yahr has 25 bells (~74 min)
+ # pahr-to-vo (bell) each yahr has 25 bells (~74 min)
('gahr-tah-vo', 25), # ~6h 3min
('tah-vo', 25), # ~14,5 min
('gor-ahn', 25), # ~34,8 seconds
@@ -206,8 +214,8 @@
sec = hahr_sec + BASE_SEC + prorahn_sec
return UTC.localize(datetime.utcfromtimestamp(sec))
- def secondsToBell(self, bell):
- """Calculate seconds until bell
+ def secondsToPahrtovo(self, bell):
+ """Calculate seconds until bell (pahr-to-vo)
"""
if bell < 1 or bell > 25:
raise ValueError("%s too large or small" % bell)
@@ -257,9 +265,9 @@
self._addProrahn(value * 15625)
gahrtahvo = property(_getGahrtahvo, _setGahrtahvo)
- def _getBell(self):
+ def _getPahrtovo(self):
return (self._prorahn // 3125) % 25
- bell = property(_getBell)
+ pahrtovo = property(_getPahrtovo)
def _getTahvo(self):
return (self._prorahn // 625) % 25
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-14 22:48:23
|
Revision: 167
http://pymoul.svn.sourceforge.net/pymoul/?rev=167&view=rev
Author: tiran
Date: 2007-02-14 14:48:22 -0800 (Wed, 14 Feb 2007)
Log Message:
-----------
Some time and ui fixes
Modified Paths:
--------------
pymoul/trunk/src/moul/file/plasmalog.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/time/__init__.py
pymoul/trunk/src/moul/time/cavern.py
pymoul/trunk/src/moul/time/dni.py
pymoul/trunk/src/moul/time/utils.py
Modified: pymoul/trunk/src/moul/file/plasmalog.py
===================================================================
--- pymoul/trunk/src/moul/file/plasmalog.py 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/file/plasmalog.py 2007-02-14 22:48:22 UTC (rev 167)
@@ -72,7 +72,7 @@
"""
self._dozip = bool(boolean)
- def setRemoe(self, boolean):
+ def setRemove(self, boolean):
"""Set remoe flag
"""
self._doremove = bool(boolean)
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-14 22:48:22 UTC (rev 167)
@@ -334,6 +334,12 @@
"""
mb = qtutils.notImplementedMB(self)
mb.exec_()
+ return
+ logzipper = self.urupersonaldr.logzipper
+ logzipper.setZip(self.radio_ziplogs.isChecked()
+ # always remove
+ logzipper.setRemove(True)
+ #doremove = self.radio_deletelogs.isChecked()
# ************************************************************************
# system tray
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-14 22:48:22 UTC (rev 167)
@@ -244,7 +244,7 @@
<bool>true</bool>
</property>
<property name="text" >
- <string>Zip debug logs</string>
+ <string>Zip and delete debug logs</string>
</property>
<property name="checked" >
<bool>true</bool>
@@ -266,7 +266,7 @@
<item row="1" column="1" colspan="3" >
<widget class="QLabel" name="lb_log_remove" >
<property name="text" >
- <string>Remove zipped logs</string>
+ <string>Remove all zipped logs</string>
</property>
<property name="buddy" >
<cstring>pb_log_remove</cstring>
Modified: pymoul/trunk/src/moul/time/__init__.py
===================================================================
--- pymoul/trunk/src/moul/time/__init__.py 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/time/__init__.py 2007-02-14 22:48:22 UTC (rev 167)
@@ -21,8 +21,4 @@
__version__ = "$Id$"
__revision__ = "$Revision$"
-from moul.osdependent import __FROZEN__
-# pytz is an egg
-if not __FROZEN__:
- import pkg_resources
- pkg_resources.require("pytz>=2006p")
+import moul.time.utils
Modified: pymoul/trunk/src/moul/time/cavern.py
===================================================================
--- pymoul/trunk/src/moul/time/cavern.py 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/time/cavern.py 2007-02-14 22:48:22 UTC (rev 167)
@@ -24,14 +24,14 @@
__all__ = ['CavernTime']
from datetime import datetime
-from pytz import all_timezones
-from pytz import timezone
-from pytz import utc as UTC
+from moul.time.utils import diffTD
+from moul.time.utils import normalizeTZ
from moul.time.utils import td2sec
-from moul.time.utils import diffTD
+from moul.time.utils import timezone
from moul.time.utils import utcnow
-from moul.time.utils import normalizeTZ
+from moul.time.utils import UNIX_0
+from moul.time.utils import UTC
## not used in the current version
#SUPPORTED_TZ = ('America', 'Canada', 'Etc', 'Europe', 'US')
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-14 22:48:22 UTC (rev 167)
@@ -94,13 +94,14 @@
__revision__ = "$Revision$"
from datetime import datetime
-from pytz import utc as UTC
-from pytz import timezone
from time import mktime
import sys
from moul.time.utils import td2sec
+from moul.time.utils import timezone
from moul.time.utils import utcnow
+from moul.time.utils import UNIX_0
+from moul.time.utils import UTC
# list of month names with approx. dates
VAILEETEE = (
@@ -120,8 +121,6 @@
BASE_GREGORIAN = datetime(1998, 4, 21, 10, 35, 18, 0, tzinfo=UTC)
BASE_HAHR = 9654
FAHRAH_1 = -7656 # hahrtee fahrah 1 starts ~April 21st 7656 B.C
-# timestamp 0 - start of unix time
-UNIX_0 = datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=UTC)
BASE_SEC = td2sec(BASE_GREGORIAN - UNIX_0) # WTF? no tottimestamp in datetime
# factors
Modified: pymoul/trunk/src/moul/time/utils.py
===================================================================
--- pymoul/trunk/src/moul/time/utils.py 2007-02-14 22:47:45 UTC (rev 166)
+++ pymoul/trunk/src/moul/time/utils.py 2007-02-14 22:48:22 UTC (rev 167)
@@ -21,9 +21,18 @@
__version__ = "$Id: cavern.py 124 2007-02-02 17:45:42Z tiran $"
__revision__ = "$Revision: 124 $"
+from moul.osdependent import __FROZEN__
+# pytz is an egg
+if not __FROZEN__:
+ import pkg_resources
+ pkg_resources.require("pytz>=2006p")
+
from datetime import datetime
from pytz import utc as UTC
+from pytz import timezone
+# timestamp 0 - start of unix time
+UNIX_0 = datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=UTC)
def diffTD(td1, td2):
"""Difference of two time delta objects -> int
@@ -71,4 +80,6 @@
"""
if utc_dt is None:
utc_dt = utcnow()
+ if isinstance(tz, basestring):
+ tz = timezone(tz)
return tz.normalize(utc_dt.astimezone(tz))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-19 16:36:33
|
Revision: 177
http://pymoul.svn.sourceforge.net/pymoul/?rev=177&view=rev
Author: tiran
Date: 2007-02-19 08:36:31 -0800 (Mon, 19 Feb 2007)
Log Message:
-----------
Enhanced D'ni clock
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/time/utils.py
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-17 21:49:15 UTC (rev 176)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-19 16:36:31 UTC (rev 177)
@@ -23,6 +23,7 @@
__revision__ = "$Revision$"
import operator
+import math
import sys
from PyQt4 import QtCore
from PyQt4 import QtGui
@@ -53,28 +54,42 @@
def initialize(self):
# D'ni numbers
self.dninumbers = QDniNumbers()
- self.dnitime = DniTime()
- self.setup_dniclock()
+ self.caverntime = CavernTime()
self.setup_dninumbers()
+
# D'ni date and time
+ view = self.gv_dniclock
+ self.clockscene = QDniClockScene(view.parent())
+ view.setScene(self.clockscene)
+ view.show()
self.dnitime_timer = QtCore.QTimer(self.context)
- self.dnitime_timer.setInterval(FACTOR_SP*1000)
- self.connect(self.dnitime_timer, SIGNAL('timeout()'),
- self.on_dnitimer_timeout)
- self.dnitime_timer.start()
- self.on_dnitimer_timeout(True)
+ self.dnitime_timer.setInterval(FACTOR_SP*1000+60) # XXX: smooth
# time zone
- self.caverntime = CavernTime()
- self.timezone_update()
# TODO: change timer from every second to every minute
self.timezone_timer = QtCore.QTimer(self.context)
self.timezone_timer.setInterval(1000) # 1 sec
# TODO: needs optimization? run only when timer tab is active
self.connect(self.timezone_timer, SIGNAL('timeout()'),
self.on_timezone_timer_timeout)
- self.timezone_timer.start()
+ self.connect(self.dnitime_timer, SIGNAL('timeout()'),
+ self.clockscene.timeEvent)
+ self.connect(self.context, SIGNAL("timerEnable(bool)"),
+ self.on_timer_timerEnable)
+ self.emit(SIGNAL("timerEnable(bool)"), True)
+ @pyqtSignature("bool")
+ def on_timer_timerEnable(self, value=True):
+ value = bool(value)
+ for timer in (self.dnitime_timer, self.timezone_timer):
+ if value == timer.isActive():
+ pass
+ elif value:
+ timer.emit(SIGNAL("timeout()")) # emit to update
+ timer.start()
+ else:
+ timer.stop()
+
def timezone_update(self):
"""
Update datetime widgets
@@ -102,74 +117,6 @@
self.dt_cavern.setDateTime(ct['cavern'])
self.dt_pacific.setDateTime(ct['pacific'])
- @pyqtSignature("")
- @skipLogging
- def on_dnitimer_timeout(self, initialize=False):
- """
- SIGNAL: QTimer timeout
- """
- self.dnitime.fromUTC() # set to now
- self.context.le_dnitime.setText(str(self.dnitime)+", bell: %s" %
- self.dnitime.pahrtovo)
- self.setClockByDnidate(self.dnitime, initialize)
-
- def setup_dniclock(self):
- height = 15
- space = 5
- width = self.dninumbers.get(0, height=height).width()
- widthl = self.dninumbers.getLeft(0, height=height).width()
- widthm = self.dninumbers.getMiddle(0, height=height).width()
- widthr = self.dninumbers.getRight(0, height=height).width()
- widthhahr = widthl + widthm + widthr
- widthyahr = widthhahr + 2 * space + width
-
- view = self.gv_dniclock
- dniclock = self.dniclock = QtGui.QGraphicsScene(view.parent())
- view.setScene(self.dniclock)
- view.show()
-
- self.hahrl = QDniNumberRing(dniclock, 0, 24, height, 'left')
- self.hahrl.setPos(0, height+space)
- self.hahrm = QDniNumberRing(dniclock, 0, 24, height, 'middle')
- self.hahrm.setPos(widthl, height+space)
- self.hahrr = QDniNumberRing(dniclock, 0, 24, height, 'right')
- self.hahrr.setPos(widthl+widthm, height+space)
-
- self.vailee = QDniNumberRing(dniclock, 1, 10, height)
- self.vailee.setPos(widthhahr+space, height+space)
- self.yahrl = QDniNumberRing(dniclock, 0, 10, height, 'left')
- self.yahrl.setPos(widthyahr, height+space)
- self.yahrr = QDniNumberRing(dniclock, 0, 24, height, 'right')
- self.yahrr.setPos(widthyahr+widthl, height+space)
- for i, name in enumerate(('gahrtahvo', 'tahvo', 'gorahn', 'prorahn')):
- ring = QDniNumberRing(dniclock, 0, 24, height, cyclic=True)
- setattr(self, name, ring)
- ring.setPos((width+space)*i+width/2, 0)
- #ring.setNumber(i)
-
- #for i, ring in enumerate((self.hahrl, self.hahrm, self.hahrr, self.vailee,
- #self.yahrl, self.yahrr)):
- #ring.setNumber(i)
-
- def setClockByDnidate(self, dnitime, initialize=False):
- if dnitime.prorahn == self.prorahn.get() and not initialize:
- return
- hahr = decimal2dni(dnitime.hahr, digits=3)
- self.hahrl.setNumber(hahr[0])
- self.hahrm.setNumber(hahr[1])
- self.hahrr.setNumber(hahr[2])
-
- self.vailee.setNumber(dnitime.vailee)
-
- yahr = decimal2dni(dnitime.yahr, digits=2)
- self.yahrl.setNumber(yahr[0])
- self.yahrr.setNumber(yahr[1])
-
- self.gahrtahvo.setNumber(dnitime.gahrtahvo)
- self.tahvo.setNumber(dnitime.tahvo)
- self.gorahn.setNumber(dnitime.gorahn)
- self.prorahn.setNumber(dnitime.prorahn)
-
def setup_dninumbers(self):
# may change!
widget = self.context.gridLayout_3
@@ -222,8 +169,6 @@
dnipix.setPosition(grid, 5, 0, QtCore.Qt.AlignRight)
grid.addWidget(dnipix, 5, 0, 1, 2)
-QtGui.QPixmapCache.setCacheLimit(QtGui.QPixmapCache.cacheLimit() + 1024)
-
class QDniNumbers(object):
"""Qt D'ni Number helper class
@@ -232,6 +177,9 @@
efficency drawbacks
"""
__slots__ = ()
+
+ QtGui.QPixmapCache.setCacheLimit(QtGui.QPixmapCache.cacheLimit() + 1024)
+
# w, h = 67, 55
_rectleft = QtCore.QRect(0, 0, 60, 55) # with right border
_rectright = QtCore.QRect(12, 0, 55, 55) # w/o left border
@@ -257,7 +205,8 @@
else:
return pm
- def get(self, nr, height=None):
+ @classmethod
+ def get(cls, nr, height=None):
"""Get pixmap by number and scale it
@param nr: number (0-25, 'cyclic')
@@ -267,7 +216,7 @@
@return: (scaled) pixmap
@rtype: QPixmap instance
"""
- pm = self._findCache(nr, height, 'full')
+ pm = cls._findCache(nr, height, 'full')
if pm:
return pm
@@ -277,20 +226,21 @@
nr = int(nr)
fname = "%02i.png" % nr
- if nr not in self._valid:
+ if nr not in cls._valid:
raise ValueError(nr)
# lookup non scaled
- pm = self._findCache(nr, None, 'full')
+ pm = cls._findCache(nr, None, 'full')
if not pm:
pm = QtGui.QPixmap(":/dninumbers/resources/dninumbers/%s" % fname)
- self._insertCache(nr, None, 'full', pm)
+ cls._insertCache(nr, None, 'full', pm)
- spm = self._scale(pm, height)
- self._insertCache(nr, height, 'full', spm)
+ spm = cls._scale(pm, height)
+ cls._insertCache(nr, height, 'full', spm)
return spm
- def getLeft(self, nr, height=None):
+ @classmethod
+ def getLeft(cls, nr, height=None):
"""Get pixmap for left digit of combined number
@param nr: number (0-25, 'cyclic')
@@ -300,15 +250,16 @@
@return: (scaled) pixmap
@rtype: QPixmap instance
"""
- pm = self._findCache(nr, height, 'left')
+ pm = cls._findCache(nr, height, 'left')
if pm:
return pm
- pm = self.get(nr).copy(self._rectleft)
- spm = self._scale(pm, height)
- self._insertCache(nr, height, 'left', spm)
+ pm = cls.get(nr).copy(cls._rectleft)
+ spm = cls._scale(pm, height)
+ cls._insertCache(nr, height, 'left', spm)
return spm
- def getRight(self, nr, height=None):
+ @classmethod
+ def getRight(cls, nr, height=None):
"""Get pixmap for right digit of combined number
@param nr: number (0-25, 'cyclic')
@@ -318,15 +269,16 @@
@return: (scaled) pixmap
@rtype: QPixmap instance
"""
- pm = self._findCache(nr, height, 'right')
+ pm = cls._findCache(nr, height, 'right')
if pm:
return pm
- pm = self.get(nr).copy(self._rectright)
- spm = self._scale(pm, height)
- self._insertCache(nr, height, 'right', spm)
+ pm = cls.get(nr).copy(cls._rectright)
+ spm = cls._scale(pm, height)
+ cls._insertCache(nr, height, 'right', spm)
return spm
- def getMiddle(self, nr, height=None):
+ @classmethod
+ def getMiddle(cls, nr, height=None):
"""Get pixmap for middle digit of combined number
@param nr: number (0-25, 'cyclic')
@@ -336,31 +288,285 @@
@return: (scaled) pixmap
@rtype: QPixmap instance
"""
- pm = self._findCache(nr, height, 'middle')
+ pm = cls._findCache(nr, height, 'middle')
if pm:
return pm
- pm = self.get(nr).copy(self._rectmiddle)
- spm = self._scale(pm, height)
- self._insertCache(nr, height, 'middle', spm)
+ pm = cls.get(nr).copy(cls._rectmiddle)
+ spm = cls._scale(pm, height)
+ cls._insertCache(nr, height, 'middle', spm)
return spm
- def getFactory(self, model='full'):
+ @classmethod
+ def getFactory(cls, model='full'):
"""Get factory method for model
"""
if model == 'full':
- return self.get
+ return cls.get
elif model == 'left':
- return self.getLeft
+ return cls.getLeft
elif model == 'right':
- return self.getRight
+ return cls.getRight
elif model == 'middle':
- return self.getMiddle
+ return cls.getMiddle
else:
raise ValueError(model)
+class QDniNumberRing(object):
+ """Qt D'ni number graphics item ring
+
+ The class emulates a ring structure similar to a clock. Internally it
+ stores a list of QGraphicsPixmapItem assossiacted with a scene. All items
+ are hidden by default and at position (0,0)
+
+ >>> example = QDniNumberRing(scene, start=1, stop=25)
+ >>> example.setPosition(24)
+ 24
+ >>> example.next()
+ 25
+ >>> example.next()
+ 1
+ """
+ __slots__ = ('_elements', '_first', '_last', '_pos')
+
+ def __init__(self, scene, start=0, stop=24, height=None,
+ model='full', cyclic=False):
+ factory = QDniNumbers().getFactory(model)
+ self._elements = []
+ self._first = start
+ self._last = stop
+ self._pos = start
+ for i in range(start, stop+1):
+ if cyclic and i == 0:
+ i = 'cyclic'
+ pmitem = QtGui.QGraphicsPixmapItem(factory(i, height=height))
+ pmitem.hide()
+ scene.addItem(pmitem)
+ self._elements.append(pmitem)
+
+ def __getitem__(self, pos):
+ return self._elements[pos - self._first]
+
+ def get(self):
+ return self._pos
+
+ def next(self):
+ """Get next item
+
+ Hides the current item and returns the next item after it is made visible
+ """
+ pos = self._pos
+ self[pos].hide()
+ pos += 1
+ if pos > self._last:
+ pos = self._first
+ self._pos = pos
+ element = self[pos]
+ element.show()
+ return pos
+
+ def setNumber(self, nr):
+ """Set current number to nr
+
+ Also hides all elements before returning the current element
+ """
+ for element in self._elements:
+ element.hide()
+ element = self[nr]
+ element.show()
+ self._pos = nr
+ return nr
+
+ def setPos(self, xpos, y=None):
+ """Set position of element
+ """
+ for element in self._elements:
+ if y is not None:
+ element.setPos(xpos, y)
+ else:
+ element.setPos(xpos)
+
+ def moveBy(self, dx, dy):
+ """Move every elemenet
+ """
+ for element in self._elements:
+ element.moveBy(dx, dy)
+
+class QDniClockScene(QtGui.QGraphicsScene):
+ """Graphics scene for D'ni clock
+ """
+ def __init__(self, parent=None):
+ QtGui.QGraphicsScene.__init__(self, parent)
+ self.dninumbers = QDniNumbers()
+ self.dnitime = DniTime()
+
+ height = 15
+ space = 5
+ xoff = 50
+ yoff = 20
+
+ # set widths from pixmaps
+ width = self.dninumbers.get(0, height=height).width()
+ widthl = self.dninumbers.getLeft(0, height=height).width()
+ widthm = self.dninumbers.getMiddle(0, height=height).width()
+ widthr = self.dninumbers.getRight(0, height=height).width()
+ widthhahr = widthl + widthm + widthr
+ widthyahr = widthhahr + 2 * space + width
+
+ # setup clock D'ni numbers
+ self.hahrl = QDniNumberRing(self, 0, 24, height, 'left')
+ self.hahrl.setPos(0, height+space)
+ self.hahrm = QDniNumberRing(self, 0, 24, height, 'middle')
+ self.hahrm.setPos(widthl, height+space)
+ self.hahrr = QDniNumberRing(self, 0, 24, height, 'right')
+ self.hahrr.setPos(widthl+widthm, height+space)
+ self.vailee = QDniNumberRing(self, 1, 10, height)
+ self.vailee.setPos(widthhahr+space, height+space)
+ self.yahrl = QDniNumberRing(self, 0, 10, height, 'left')
+ self.yahrl.setPos(widthyahr, height+space)
+ self.yahrr = QDniNumberRing(self, 0, 24, height, 'right')
+ self.yahrr.setPos(widthyahr+widthl, height+space)
+ for i, name in enumerate(('gahrtahvo', 'tahvo', 'gorahn', 'prorahn')):
+ ring = QDniNumberRing(self, 0, 24, height, cyclic=True)
+ setattr(self, name, ring)
+ ring.setPos((width+space)*i+width/2, 0)
+
+ for value in self.__dict__.values():
+ if isinstance(value, QDniNumberRing):
+ value.moveBy(xoff, yoff)
+
+ # clock text
+ # XXX: parent?
+ self.clocktext = QtGui.QGraphicsTextItem(None, self)
+ self.clocktext.setPos(0, yoff+2*height+2*space)
+ # circular day clock
+ self.circle = QDniClockCircle(None, self)
+ self.circle.setPos(300, 3)
+
+ # initialize view
+ self.timeEvent(initialize=True)
+
+ def setClockByDnidate(self, dnitime, initialize=False):
+ if dnitime.prorahn == self.prorahn.get() and not initialize:
+ return
+
+ self.clocktext.setPlainText(str(self.dnitime))
+
+ self.circle.setPahrtovo(dnitime.pahrtovo + dnitime.tahvo / 5.0)
+
+ hahr = decimal2dni(dnitime.hahr, digits=3)
+ self.hahrl.setNumber(hahr[0])
+ self.hahrm.setNumber(hahr[1])
+ self.hahrr.setNumber(hahr[2])
+ self.vailee.setNumber(dnitime.vailee)
+ yahr = decimal2dni(dnitime.yahr, digits=2)
+ self.yahrl.setNumber(yahr[0])
+ self.yahrr.setNumber(yahr[1])
+ self.gahrtahvo.setNumber(dnitime.gahrtahvo)
+ self.tahvo.setNumber(dnitime.tahvo)
+ self.gorahn.setNumber(dnitime.gorahn)
+ self.prorahn.setNumber(dnitime.prorahn)
+
+ @pyqtSignature("")
+ @skipLogging
+ def timeEvent(self, initialize=False):
+ """
+ SIGNAL: QTimer timeout
+ """
+ self.dnitime.fromUTC() # set to now
+ self.setClockByDnidate(self.dnitime, initialize)
+
+class QDniClockCircle(QtGui.QGraphicsItem):
+ """Circular part of the D'ni clock
+ """
+ r = 45.0 # radios of circle
+ rdot = 3.0 # radius of dots
+ rinner = 5.0 # radius of inner circle
+ outrect = QtCore.QRectF(0.0, 0.0, 2.0*r, 2.0*r)
+ center = (r, r)
+ angel = 2.0*math.pi/25.0
+ offset = 0.5 * math.pi + 5.0 * angel
+
+ def __init__(self, parent=None, scene=None):
+ QtGui.QGraphicsItem.__init__(self, parent, scene)
+ self._pahrtovo = 0.0
+ self._dni =QDniNumbers()
+
+ def boundingRect(self):
+ return self.outrect
+
+ def setPahrtovo(self, value):
+ if value != self._pahrtovo:
+ self._pahrtovo = value
+ self.update()
+
+ def paint(self, painter, option, widget):
+ # pie pieces for darkness
+ painter.save()
+ painter.setBrush(QtGui.QColor(Qt.lightGray))
+ painter.setPen(QtGui.QPen(Qt.NoPen))
+ for i in (-1, 0):
+ rot = 270.0 + i*360.0/5.0 # 6 o'clock +/- angel
+ painter.drawPie(self.outrect, rot*16.0, 360.0/5.0*16.0)
+ painter.restore()
+
+ # outer circle
+ painter.drawEllipse(self.outrect)
+ # inner dot
+ painter.save()
+ painter.setBrush(QtGui.QColor(Qt.black))
+ painter.drawEllipse(self.center[0]-self.rinner/2.0,
+ self.center[1]-self.rinner/2.0,
+ self.rinner, self.rinner)
+ painter.restore()
+
+ painter.save()
+ painter.setBrush(QtGui.QBrush(QtGui.QColor(Qt.white)))
+ # stripes and dots
+ for i in range(0, 25):
+ rot = i * self.angel + self.offset
+ if i % 5 == 0:
+ # lines
+ end = QtCore.QPointF(self.center[0] + self.r * math.cos(rot),
+ self.center[1] + self.r * math.sin(rot))
+ painter.drawLine(QtCore.QPointF(*self.center), end)
+ else:
+ # outer ring of dots
+ rect = QtCore.QRectF(
+ self.center[0] - self.rdot/2 + (self.r - self.rdot-1.0) * math.cos(rot),
+ self.center[1] - self.rdot/2 + (self.r - self.rdot-1.0) * math.sin(rot),
+ self.rdot, self.rdot)
+ painter.drawEllipse(rect)
+ painter.restore()
+
+ # number
+ h = 15
+ pm = self._dni.get(self._pahrtovo, height=h)
+ w = pm.width()
+ posx, posy = self.center[0]-w/2.0, self.center[1]+10.0
+ painter.save()
+ painter.setBrush(QtGui.QBrush(QtGui.QColor(Qt.white)))
+ painter.setPen(QtGui.QPen(Qt.NoPen))
+ painter.drawRect(posx-1, posy-1, w+2, h+2)
+ painter.drawPixmap(posx, posy, pm)
+ painter.restore()
+
+ # pointer
+ painter.save()
+ pen = QtGui.QPen(Qt.black)
+ pen.setWidth(2)
+ pen.setCapStyle(Qt.RoundCap)
+ painter.setPen(pen)
+ rot = self.angel * self._pahrtovo + self.offset
+ end = QtCore.QPointF(self.center[0] + (self.r-self.rdot) * math.cos(rot),
+ self.center[1] + (self.r-self.rdot) * math.sin(rot))
+ painter.drawLine(QtCore.QPointF(*self.center), end)
+ painter.restore()
+
class QDniNumberWidget(QtGui.QWidget):
"""Q D'ni number widget
-
+
+ XXX: hacky, replace it
+
Displays combined number
"""
def __init__(self, parent):
@@ -455,77 +661,3 @@
movex = movex // 2
self.move(geometry.x()+movex, geometry.y())
self._layout = None
-
-class QDniNumberRing(object):
- """Qt D'ni number graphics item ring
-
- The class emulates a ring structure similar to a clock. Internally it
- stores a list of QGraphicsPixmapItem assossiacted with a scene. All items
- are hidden by default and at position (0,0)
-
- >>> example = QDniNumberRing(scene, start=1, stop=25)
- >>> example.setPosition(24)
- 24
- >>> example.next()
- 25
- >>> example.next()
- 1
- """
- __slots__ = ('_elements', '_first', '_last', '_pos')
-
- def __init__(self, scene, start=0, stop=24, height=None,
- model='full', cyclic=False):
- factory = QDniNumbers().getFactory(model)
- self._elements = []
- self._first = start
- self._last = stop
- self._pos = start
- for i in range(start, stop+1):
- if cyclic and i == 0:
- i = 'cyclic'
- pmitem = QtGui.QGraphicsPixmapItem(factory(i, height=height))
- pmitem.hide()
- scene.addItem(pmitem)
- self._elements.append(pmitem)
-
- def __getitem__(self, pos):
- return self._elements[pos - self._first]
-
- def get(self):
- return self._pos
-
- def next(self):
- """Get next item
-
- Hides the current item and returns the next item after it is made visible
- """
- pos = self._pos
- self[pos].hide()
- pos += 1
- if pos > self._last:
- pos = self._first
- self._pos = pos
- element = self[pos]
- element.show()
- return pos
-
- def setNumber(self, nr):
- """Set current number to nr
-
- Also hides all elements before returning the current element
- """
- for element in self._elements:
- element.hide()
- element = self[nr]
- element.show()
- self._pos = nr
- return nr
-
- def setPos(self, xpos, y=None):
- """Set position of element
- """
- for element in self._elements:
- if y is not None:
- element.setPos(xpos, y)
- else:
- element.setPos(xpos)
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-17 21:49:15 UTC (rev 176)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-19 16:36:31 UTC (rev 177)
@@ -85,20 +85,20 @@
self.urupersonaldir.initializeFactories()
# init handlers
+ self.qcDniTimeNumber = DniTimeNumberContainer(self)
+ self.qcLocalization = LocalizationContainer(self)
+ self.qcIniFile = IniFileContainer(self)
self._ping_init()
- self._systray_init()
+ #self._systray_init()
self._about_init()
self._chatlog_init()
- self.qcLocalization = LocalizationContainer(self)
- self.qcIniFile = IniFileContainer(self)
- self.qcDniTimeNumber = DniTimeNumberContainer(self)
# run checker
- self._moulrunning = None
- self._moulrunning_thread = MoulRunningThread()
- self.connect(self._moulrunning_thread, SIGNAL('moulIsRunning(bool)'),
- self.on_moulIsRunning)
- self._moulrunning_thread.startChecker(5.0) # check now and every 5 seconds
+ #self._moulrunning = None
+ #self._moulrunning_thread = MoulRunningThread()
+ #self.connect(self._moulrunning_thread, SIGNAL('moulIsRunning(bool)'),
+ # self.on_moulIsRunning)
+ #self._moulrunning_thread.startChecker(5.0) # check now and every 5 seconds
def on_moulIsRunning(self, boolean):
"""
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-17 21:49:15 UTC (rev 176)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-19 16:36:31 UTC (rev 177)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './src/moul/qt/ui/mainwindow.ui'
#
-# Created: Sat Feb 17 22:12:04 2007
+# Created: Mon Feb 19 15:44:53 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -207,16 +207,17 @@
self.gb_dnitime.setObjectName("gb_dnitime")
self.gv_dniclock = QtGui.QGraphicsView(self.gb_dnitime)
- self.gv_dniclock.setGeometry(QtCore.QRect(10,20,150,55))
+ self.gv_dniclock.setGeometry(QtCore.QRect(10,20,431,101))
+ self.gv_dniclock.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.gv_dniclock.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
self.gv_dniclock.setAcceptDrops(False)
self.gv_dniclock.setFrameShadow(QtGui.QFrame.Plain)
+ self.gv_dniclock.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
+ self.gv_dniclock.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
+ self.gv_dniclock.setInteractive(False)
+ self.gv_dniclock.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
+ self.gv_dniclock.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.SmoothPixmapTransform|QtGui.QPainter.TextAntialiasing)
self.gv_dniclock.setObjectName("gv_dniclock")
-
- self.le_dnitime = QtGui.QLineEdit(self.gb_dnitime)
- self.le_dnitime.setGeometry(QtCore.QRect(10,90,271,25))
- self.le_dnitime.setEchoMode(QtGui.QLineEdit.Normal)
- self.le_dnitime.setReadOnly(True)
- self.le_dnitime.setObjectName("le_dnitime")
self.tabwidget.addTab(self.tab_tasks,"")
self.tab_settings = QtGui.QWidget()
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-17 21:49:15 UTC (rev 176)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-19 16:36:31 UTC (rev 177)
@@ -483,32 +483,37 @@
<rect>
<x>10</x>
<y>20</y>
- <width>150</width>
- <height>55</height>
+ <width>431</width>
+ <height>101</height>
</rect>
</property>
+ <property name="focusPolicy" >
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="contextMenuPolicy" >
+ <enum>Qt::NoContextMenu</enum>
+ </property>
<property name="acceptDrops" >
<bool>false</bool>
</property>
<property name="frameShadow" >
<enum>QFrame::Plain</enum>
</property>
- </widget>
- <widget class="QLineEdit" name="le_dnitime" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>90</y>
- <width>271</width>
- <height>25</height>
- </rect>
+ <property name="verticalScrollBarPolicy" >
+ <enum>Qt::ScrollBarAlwaysOff</enum>
</property>
- <property name="echoMode" >
- <enum>QLineEdit::Normal</enum>
+ <property name="horizontalScrollBarPolicy" >
+ <enum>Qt::ScrollBarAlwaysOff</enum>
</property>
- <property name="readOnly" >
- <bool>true</bool>
+ <property name="interactive" >
+ <bool>false</bool>
</property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="renderHints" >
+ <set>QPainter::Antialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing</set>
+ </property>
</widget>
</widget>
</widget>
Modified: pymoul/trunk/src/moul/time/utils.py
===================================================================
--- pymoul/trunk/src/moul/time/utils.py 2007-02-17 21:49:15 UTC (rev 176)
+++ pymoul/trunk/src/moul/time/utils.py 2007-02-19 16:36:31 UTC (rev 177)
@@ -30,6 +30,7 @@
from datetime import datetime
from pytz import utc as UTC
from pytz import timezone
+from pytz import common_timezones
# timestamp 0 - start of unix time
UNIX_0 = datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=UTC)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-19 18:27:50
|
Revision: 179
http://pymoul.svn.sourceforge.net/pymoul/?rev=179&view=rev
Author: tiran
Date: 2007-02-19 10:27:50 -0800 (Mon, 19 Feb 2007)
Log Message:
-----------
More time stuff
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/time/dni.py
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-19 16:37:51 UTC (rev 178)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-19 18:27:50 UTC (rev 179)
@@ -66,16 +66,22 @@
self.dnitime_timer.setInterval(FACTOR_SP*1000+60) # XXX: smooth
# time zone
- # TODO: change timer from every second to every minute
+ # TODO: change timer from every second to once a minute?
self.timezone_timer = QtCore.QTimer(self.context)
self.timezone_timer.setInterval(1000) # 1 sec
- # TODO: needs optimization? run only when timer tab is active
+ ct = self.caverntime.info()
+ off = ct['cavern']['utcoffset']
+ self.lb_cavern_utc.setText("UTC %s%i" % (off[0], abs(off[1])))
+ off = ct['pacific']['utcoffset']
+ self.lb_pacific_utc.setText("UTC %s%i" % (off[0], abs(off[1])))
+
self.connect(self.timezone_timer, SIGNAL('timeout()'),
self.on_timezone_timer_timeout)
self.connect(self.dnitime_timer, SIGNAL('timeout()'),
self.clockscene.timeEvent)
self.connect(self.context, SIGNAL("timerEnable(bool)"),
self.on_timer_timerEnable)
+ # TODO: needs optimization? run only when timer tab is active
self.emit(SIGNAL("timerEnable(bool)"), True)
@pyqtSignature("bool")
@@ -90,23 +96,6 @@
else:
timer.stop()
- def timezone_update(self):
- """
- Update datetime widgets
- """
- ct = self.caverntime.info()
-
- self.dt_cavern.setDateTime(ct['cavern']['datetime'])
- self.dt_pacific.setDateTime(ct['pacific']['datetime'])
-
- off = ct['cavern']['utcoffset']
- txt = "UTC %s%i" % (off[0], abs(off[1]))
- self.lb_cavern_utc.setText(QtCore.QString(txt))
-
- off = ct['pacific']['utcoffset']
- txt = "UTC %s%i" % (off[0], abs(off[1]))
- self.lb_pacific_utc.setText(QtCore.QString(txt))
-
@pyqtSignature("")
@skipLogging
def on_timezone_timer_timeout(self):
@@ -451,7 +440,7 @@
self.clocktext.setPlainText(str(self.dnitime))
- self.circle.setPahrtovo(dnitime.pahrtovo + dnitime.tahvo / 5.0)
+ self.circle.setPahrtovo(dnitime.getPahrtovoFraction())
hahr = decimal2dni(dnitime.hahr, digits=3)
self.hahrl.setNumber(hahr[0])
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-19 16:37:51 UTC (rev 178)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-19 18:27:50 UTC (rev 179)
@@ -130,10 +130,9 @@
@param event: close event
@type event: QCloseEvent instance
"""
- accept = self.handleDirtyOnClose()
- if accept:
- self._systray_close()
- self._moulrunning_thread.terminate()
+ if self.handleDirtyOnClose():
+ #self._systray_close()
+ #self._moulrunning_thread.terminate()
event.accept()
else:
event.ignore()
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-19 16:37:51 UTC (rev 178)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-19 18:27:50 UTC (rev 179)
@@ -298,6 +298,11 @@
return (self._prorahn // PRORAHN_PER_PAHRTOVO) % 25
pahrtovo = property(_getPahrtovo)
+ def getPahrtovoFraction(self):
+ """Get Pahrtovo with decimal fraction
+ """
+ return ((self._prorahn // PRORAHN_PER_TAHVO) % 125) / 5.0
+
def _getTahvo(self):
return (self._prorahn // PRORAHN_PER_TAHVO) % 25
@valueCheck(int, 0, 25)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-22 14:42:23
|
Revision: 182
http://pymoul.svn.sourceforge.net/pymoul/?rev=182&view=rev
Author: tiran
Date: 2007-02-22 06:42:24 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
Clean up logging
Modified Paths:
--------------
pymoul/trunk/src/moul/crypt/whatdoyousee.py
pymoul/trunk/src/moul/file/chatlog.py
pymoul/trunk/src/moul/file/directory.py
pymoul/trunk/src/moul/file/kiimage.py
pymoul/trunk/src/moul/file/localization.py
pymoul/trunk/src/moul/file/plasmalog.py
pymoul/trunk/src/moul/file/wdysini.py
pymoul/trunk/src/moul/log.py
pymoul/trunk/src/moul/osdependent/darwin/__init__.py
pymoul/trunk/src/moul/osdependent/linux/__init__.py
pymoul/trunk/src/moul/osdependent/win32/__init__.py
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/qt/errorhandler.py
pymoul/trunk/src/moul/qt/i18n/__init__.py
pymoul/trunk/src/moul/qt/localization.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/moulqt.py
pymoul/trunk/src/moul/qt/utils.py
pymoul/trunk/src/moul/qt/wdysini.py
pymoul/trunk/src/moul/time/utils.py
Modified: pymoul/trunk/src/moul/crypt/whatdoyousee.py
===================================================================
--- pymoul/trunk/src/moul/crypt/whatdoyousee.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/crypt/whatdoyousee.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -33,7 +33,7 @@
from moul.crypt.xtea import xtea_decrypt
from moul.crypt.xtea import xtea_encrypt
from moul.crypt.binary import BinaryFile
-from moul.log import getLogger
+from logging import getLogger
HEADER = "whatdoyousee"
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -39,7 +39,7 @@
from time import localtime
from moul.file.utils import fileModTime
-from moul.log import getLogger
+from logging import getLogger
RE_FLAGS = re.LOCALE
Modified: pymoul/trunk/src/moul/file/directory.py
===================================================================
--- pymoul/trunk/src/moul/file/directory.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/file/directory.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -30,7 +30,7 @@
from moul.file.plasmalog import PlasmalogZipper
from moul.file.wdysini import AudioIni
from moul.file.wdysini import GraphicsIni
-from moul.log import getLogger
+from logging import getLogger
LOG = getLogger('moul.file.directory')
Modified: pymoul/trunk/src/moul/file/kiimage.py
===================================================================
--- pymoul/trunk/src/moul/file/kiimage.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/file/kiimage.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -29,7 +29,7 @@
from moul.file.utils import fileModTime
from moul.file.utils import fileSize
-from moul.log import getLogger
+from logging import getLogger
KINUMBER_RE = re.compile("(\d+)\.jpg$", re.IGNORECASE)
JPEG_HEADER = "\377\330\377"
Modified: pymoul/trunk/src/moul/file/localization.py
===================================================================
--- pymoul/trunk/src/moul/file/localization.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/file/localization.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -26,7 +26,7 @@
from xml.sax.handler import feature_namespaces
from xml.sax.saxutils import unescape
-from moul.log import getLogger
+from logging import getLogger
__author__ = "Christian Heimes"
__version__ = "$Id$"
Modified: pymoul/trunk/src/moul/file/plasmalog.py
===================================================================
--- pymoul/trunk/src/moul/file/plasmalog.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/file/plasmalog.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -29,7 +29,7 @@
from moul.crypt.elf import decryptElf
from moul.file.utils import fileModTime
-from moul.log import getLogger
+from logging import getLogger
PLASMA_LOG = "plasmalog.txt"
Modified: pymoul/trunk/src/moul/file/wdysini.py
===================================================================
--- pymoul/trunk/src/moul/file/wdysini.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/file/wdysini.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -26,7 +26,7 @@
from moul.crypt.whatdoyousee import decryptWDYS
from moul.crypt.whatdoyousee import encryptWDYS
-from moul.log import getLogger
+from logging import getLogger
LOG = getLogger('moul.file.wdysini')
Modified: pymoul/trunk/src/moul/log.py
===================================================================
--- pymoul/trunk/src/moul/log.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/log.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -35,98 +35,109 @@
from moul.metadata import __version__ as moul_version
+LOG = logging.getLogger('pyMoul')
-getLogger = logging.getLogger
-
-__FROZEN__ = bool(getattr(sys, 'frozen', False))
-
-format = Formatter('%(asctime)s %(name)-8s %(levelname)-7s %(message)s',
- #'%a, %d %b %Y %H:%M:%S'
- '%H:%M:%S')
-root = getLogger()
-root.setLevel(logging.DEBUG)
-LOG = getLogger('pyMoul')
-
class LoggingStdout(object):
"""Replacement for stdout/stderr IO
"""
__slot__ = ('_logfunc',)
-
+
def __init__(self, logfunc):
self._logfunc = logfunc
-
+
def write(self, value):
while value.endswith('\n'):
value = value[:-1]
if value:
self._logfunc(value)
-mhdlr = None
-fhdlr = None
-def _installMemoryHdlr():
- """setup a memory handler to store records before we have the
- infrastructure to log events to a file
+class LoggerSetup(object):
+ """Setup logger
"""
- global mhdlr
- mhdlr = handlers.MemoryHandler(capacity=4*1024) # MemoryHandler doesn't flush w/o a target
- mhdlr.setFormatter(format)
- root.addHandler(mhdlr)
+ format = Formatter('%(asctime)s %(name)-8s %(levelname)-7s %(message)s',
+ #'%a, %d %b %Y %H:%M:%S'
+ '%H:%M:%S')
-def _removeMemoryHdlr():
- """Remove memory handler
- """
- global mhdlr
- global fhdlr
- if mhdlr:
- mhdlr.setTarget(fhdlr)
- mhdlr.flush()
- root.removeHandler(mhdlr)
- del mhdlr
+ frozen = bool(getattr(sys, 'frozen', False))
+ level = logging.DEBUG
-def _installFileHdlr():
- """Install a file handler
- """
- global fhdlr
- from moul.config import getPyMoulDataDir
- logFile = os.path.join(getPyMoulDataDir(check=True), 'pymoul.log')
- LOG.info("Adding file logger: %s" % logFile)
- fhdlr = handlers.RotatingFileHandler(logFile, backupCount=9)
- fhdlr.setFormatter(format)
- root.addHandler(fhdlr)
- fhdlr.doRollover()
+ def __init__(self):
+ self.root = logging.getLogger()
+ self.root.setLevel(self.level)
+ self.mhdlr = None
+ self.fhdlr = None
-def _systemInfo():
- from moul.osdependent import __INFO__
- LOG.info("time: " + time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))
- LOG.info("pyMoul version: %s" % moul_version)
- LOG.info("Python: %s" % repr(sys.version_info))
- LOG.info("Python: %s" % sys.version.replace('\n', ' '))
- LOG.info("Platform: %s, OS name: %s" % (sys.platform, os.name))
- LOG.info("system %r, node %r, release %r, version %r, machine %r, processor %r"
- % platform.uname())
- LOG.info("platform name: %s" % platform.platform(True))
- LOG.info("sys.frozen status: %s" % __FROZEN__)
- LOG.info("OS detected: win32: %r, cygwin: %r, Linux: %r, Mac: %r, BSD: %r, "
- "posix/Un*x: %r, NT: %r" % __INFO__)
+ def _installMemoryHdlr(self):
+ """setup a memory handler to store records before we have the
+ infrastructure to log events to a file
+ """
+ # MemoryHandler doesn't flush w/o a target
+ self.mhdlr = handlers.MemoryHandler(capacity=4*1024)
+ self.mhdlr.setFormatter(self.format)
+ self.root.addHandler(mhdlr)
-# no setup the logging stuff!
+ def _removeMemoryHdlr(self):
+ """Remove memory handler
-if not __FROZEN__:
- # Add streaming handler to sys.stderr.
- # Only log to stderr when the program is not frozen!
- shdlr = logging.StreamHandler(sys.stderr)
- shdlr.setFormatter(format)
- root.addHandler(shdlr)
- #_systemInfo()
-else:
- _installMemoryHdlr()
- _systemInfo()
+ Flush content to file handler
+ """
+ if self.mhdlr:
+ self.mhdlr.setTarget(self.fhdlr)
+ self.mhdlr.flush()
+ self.root.removeHandler(self.mhdlr)
+ self.mhdlr = None
-def createLogfile():
- """Create log file and redirect stdout/stderr to logfile
- """
- _installFileHdlr()
- _removeMemoryHdlr()
- # Redirect stdout and stderr to logger when running as frozen app
- #sys.stdout = LoggingStdout(getLogger('stdout').info)
- #sys.stderr = LoggingStdout(getLogger('stderr').error)
+ def _installFileHdlr(self):
+ """Install a file handler
+ """
+ from moul.config import getPyMoulDataDir
+ logFile = os.path.join(getPyMoulDataDir(check=True), 'pymoul.log')
+ LOG.info("Adding file logger: %s" % logFile)
+ self.fhdlr = handlers.RotatingFileHandler(logFile, backupCount=9)
+ self.fhdlr.setFormatter(self.format)
+ self.root.addHandler(self.fhdlr)
+ self.fhdlr.doRollover()
+
+ def _installStreamStderr(self):
+ """Install stream handler to stderr
+ """
+ shdlr = logging.StreamHandler(sys.stderr)
+ shdlr.setFormatter(self.format)
+ self.root.addHandler(shdlr)
+
+ def _redirectStdout(self):
+ """Redirect stdout and stderr to logger
+ """
+ sys.stdout = LoggingStdout(getLogger('stdout').info)
+ sys.stderr = LoggingStdout(getLogger('stderr').error)
+
+ def _systemInfo(self):
+ from moul.osdependent import __INFO__
+ LOG.info("time: " + time.strftime("%a, %d %b %Y %H:%M:%S +0000",
+ time.gmtime()))
+ LOG.info("pyMoul version: %s" % moul_version)
+ LOG.info("Python: %s" % repr(sys.version_info))
+ LOG.info("Python: %s" % sys.version.replace('\n', ' '))
+ LOG.info("Platform: %s, OS name: %s" % (sys.platform, os.name))
+ LOG.info("system %r, node %r, release %r, version %r, machine %r, "
+ "processor %r" % platform.uname())
+ LOG.info("platform name: %s" % platform.platform(True))
+ LOG.info("sys.frozen status: %s" % self.frozen)
+ LOG.info("OS detected: win32: %r, cygwin: %r, Linux: %r, Mac: %r, "
+ "BSD: %r, posix/Un*x: %r, NT: %r" % __INFO__)
+
+ def __call__(self):
+ if not self.frozen:
+ self._installStreamStderr()
+ else:
+ self._installMemoryHdlr()
+ self._systemInfo()
+
+ def createLogfile(self):
+ self._installFileHdlr()
+ self._removeMemoryHdlr()
+
+loggerSetup = LoggerSetup()
+createLogfile = loggerSetup.createLogfile
+
+loggerSetup()
Modified: pymoul/trunk/src/moul/osdependent/darwin/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/darwin/__init__.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/osdependent/darwin/__init__.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -24,7 +24,7 @@
import os
from subprocess import Popen
-from moul.log import getLogger
+from logging import getLogger
LOG = getLogger('moul.darwin')
Modified: pymoul/trunk/src/moul/osdependent/linux/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/linux/__init__.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/osdependent/linux/__init__.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -25,7 +25,7 @@
from subprocess import Popen
from moul.osdependent.processinfo import getPidNames
-from moul.log import getLogger
+from logging import getLogger
LOG = getLogger('moul.linux')
Modified: pymoul/trunk/src/moul/osdependent/win32/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/win32/__init__.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/osdependent/win32/__init__.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -24,7 +24,7 @@
import os
from subprocess import Popen
-from moul.log import getLogger
+from logging import getLogger
from moul.osdependent.processinfo import getPidNames
from moul.osdependent.win32 import winpath
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -40,7 +40,7 @@
from moul.time.dni import DNI_HOLIDAYS
from moul.time.utils import ts2utc
from moul.time.utils import utcnow
-from moul.log import getLogger
+from logging import getLogger
from moul.qt.utils import QNamespaceContainer
from moul.qt.utils import QSignalLoggerMetaclass
from moul.qt.utils import skipLogging
Modified: pymoul/trunk/src/moul/qt/errorhandler.py
===================================================================
--- pymoul/trunk/src/moul/qt/errorhandler.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/errorhandler.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -31,7 +31,7 @@
from PyQt4.QtGui import QApplication
from traceback import format_exception
-from moul.log import getLogger
+from logging import getLogger
from moul.qt.utils import criticalMB
Modified: pymoul/trunk/src/moul/qt/i18n/__init__.py
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/__init__.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/i18n/__init__.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -29,7 +29,7 @@
from PyQt4 import QtCore
from moul.osdependent import __FROZEN__
-from moul.log import getLogger
+from logging import getLogger
LOG = getLogger('moul.qt.i18n')
Modified: pymoul/trunk/src/moul/qt/localization.py
===================================================================
--- pymoul/trunk/src/moul/qt/localization.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/localization.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -31,7 +31,7 @@
from PyQt4.QtCore import pyqtSignature
from moul.file.localization import translationRegistry as tr
-from moul.log import getLogger
+from logging import getLogger
from moul.qt.simpleprogressbar import SimpleProgressbar
from moul.qt.utils import QYieldingThreadlet
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -36,7 +36,7 @@
from moul.config import lookupDir
from moul.file.directory import UruGameDataDirectory
from moul.file.directory import UruPersonalDataDirectory
-from moul.log import getLogger
+from logging import getLogger
from moul.osdependent import isMoulRunning
from moul.server.ping import ServerList
from moul.server.ping import isSocketError
Modified: pymoul/trunk/src/moul/qt/moulqt.py
===================================================================
--- pymoul/trunk/src/moul/qt/moulqt.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/moulqt.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -23,12 +23,13 @@
__version__ = "$Id$"
__revision__ = "$Revision$"
+from moul.log import createLogfile
+
import sys
from PyQt4 import QtGui
+from logging import getLogger
from moul.config import getPyMoulDataDir
-from moul.log import createLogfile
-from moul.log import getLogger
from moul.osdependent import isMoulRunning
from moul.osdependent.singleapp import SimpleSingleApp
Modified: pymoul/trunk/src/moul/qt/utils.py
===================================================================
--- pymoul/trunk/src/moul/qt/utils.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/utils.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -42,7 +42,7 @@
from types import FunctionType
from moul.osdependent import __FROZEN__
-from moul.log import getLogger
+from logging import getLogger
LOG = getLogger('moul.qt.utils')
Modified: pymoul/trunk/src/moul/qt/wdysini.py
===================================================================
--- pymoul/trunk/src/moul/qt/wdysini.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/qt/wdysini.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -36,7 +36,7 @@
from moul.file.directory import UruGameDataDirectory
from moul.file.directory import UruPersonalDataDirectory
from moul.file.wdysini import videoModes
-from moul.log import getLogger
+from logging import getLogger
from moul.qt.utils import QNamespaceContainer
from moul.qt.utils import QSignalLoggerMetaclass
from moul.qt.utils import questionMB
Modified: pymoul/trunk/src/moul/time/utils.py
===================================================================
--- pymoul/trunk/src/moul/time/utils.py 2007-02-22 14:14:24 UTC (rev 181)
+++ pymoul/trunk/src/moul/time/utils.py 2007-02-22 14:42:24 UTC (rev 182)
@@ -65,9 +65,9 @@
>>> from datetime import timedelta
>>> td2sec(timedelta(0, 3600))
- 3600
+ 3600.0
>>> td2sec(timedelta(0, -3600))
- -3600
+ -3600.0
"""
return 86400 * td.days + td.seconds + td.microseconds/1000000.0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-23 18:34:12
|
Revision: 189
http://pymoul.svn.sourceforge.net/pymoul/?rev=189&view=rev
Author: tiran
Date: 2007-02-23 10:34:10 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
Some fixes for the new time tab
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/qt/utils.py
pymoul/trunk/src/moul/time/dni.py
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-23 16:45:46 UTC (rev 188)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-23 18:34:10 UTC (rev 189)
@@ -100,7 +100,7 @@
self.connect(self.context, SIGNAL("timerEnable(bool)"),
self.on_timer_timerEnable)
# TODO: needs optimization? run only when timer tab is active
- for name in ('sb_hahr', 'sb_yahr', 'sb_gahrtahvo',
+ for name in ('sb_hahr', 'sb_yahr', 'sb_gahrtahvo',
'sb_tahvo', 'sb_gorahn', 'sb_prorahn'):
self.connect(getattr(self, name), SIGNAL("valueChanged(int)"),
self.update_dni)
@@ -140,6 +140,7 @@
self.dnitime.fromUTC()
self.clockscene.setClockFromDniTime(self.dnitime)
self.setWidgetDniTime(self.dnitime)
+ self.dte_earthtime.setDateTime(dt2qdt(self.dnitime.toUTC()))
@pyqtSignature("bool")
def on_rb_curtime_clicked(self, value):
@@ -150,45 +151,49 @@
def on_rb_earthtime_clicked(self, value):
if value:
self.emit(SIGNAL("timerEnable(bool)"), False)
- self.update_earthtime(self.dte_earthtime.dateTime())
+ self.update_earthtime()
@pyqtSignature("bool")
def on_rb_dnitime_clicked(self, value):
if value:
self.emit(SIGNAL("timerEnable(bool)"), False)
+ self.update_dni()
@pyqtSignature("bool")
- def on_rb_dniholiday_clicked(self, value):
+ def on_rb_dniholidays_clicked(self, value):
if value:
self.emit(SIGNAL("timerEnable(bool)"), False)
+ self.update_dniholidays()
@pyqtSignature("int")
- def on_sb_fahrah_valueChanged(self, value):
+ def on_sb_fahrah_valueChanged(self, fahrah):
hahr = self.sb_fahrah_hahr.value()
- self.sb_hahr.setValue(value * 625 + hahr)
+ self.sb_hahr.setValue(fahrah * 625 + hahr)
@pyqtSignature("int")
- def on_sb_fahrah_hahr_valueChanged(self, value):
+ def on_sb_fahrah_hahr_valueChanged(self, hahr):
fahrah = self.sb_fahrah.value()
- self.sb_hahr.setValue(fahrah * 625 + value)
+ self.sb_hahr.setValue(fahrah * 625 + hahr)
@pyqtSignature("int")
def on_sb_hahr_valueChanged(self, value):
fahrah = value // 625
- hahr = value - fahrah * 625
+ hahr = value - (fahrah * 625)
+ print fahrah, hahr
self.sb_fahrah_hahr.setValue(hahr)
self.sb_fahrah.setValue(fahrah)
@pyqtSignature("int")
def on_cb_dniholidays_currentIndexChanged(self, idx):
- self.rb_dniholidays.setChecked(True)
+ if self.rb_dniholidays.isChecked():
+ self.update_dniholidays()
@pyqtSignature("const QDateTime &")
def on_dte_earthtime_dateTimeChanged(self, qdt):
- self.rb_earthtime.setChecked(True)
- self.update_earthtime(qdt)
+ if self.rb_earthtime.isChecked():
+ self.update_earthtime()
- def update_dni(self, ignored=None):
+ def update_dni(self):
"""Update view from D'ni time widgets
"""
if not self.rb_dnitime.isChecked():
@@ -197,15 +202,15 @@
self.clockscene.setClockFromDniTime(self.dnitime)
self.dte_earthtime.setDateTime(dt2qdt(self.dnitime.toUTC()))
- def update_earthtime(self, qdt):
+ def update_earthtime(self):
"""Update view from earth time widget
"""
- dt = qdt2dt(qdt)
+ dt = qdt2dt(self.dte_earthtime.dateTime())
self.dnitime.fromUTC(dt)
self.clockscene.setClockFromDniTime(self.dnitime)
self.setWidgetDniTime(self.dnitime)
- def update_holiday(self, idx):
+ def update_dniholidays(self):
"""Update view from D'ni holiday widget
"""
@@ -615,7 +620,13 @@
painter.restore()
# outer circle
+ painter.save()
+ pen = QtGui.QPen(Qt.black)
+ pen.setWidthF(1.5)
+ pen.setCapStyle(Qt.RoundCap)
+ painter.setPen(pen)
painter.drawEllipse(self.outrect)
+ painter.restore()
# inner dot
painter.save()
painter.setBrush(QtGui.QColor(Qt.black))
@@ -654,10 +665,10 @@
painter.drawPixmap(posx, posy, pm)
#painter.restore()
- # pointer
+ # hand
painter.save()
pen = QtGui.QPen(Qt.black)
- pen.setWidth(2)
+ pen.setWidthF(2.5)
pen.setCapStyle(Qt.RoundCap)
painter.setPen(pen)
rot = self.angel * self._pahrtovo + self.offset
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-23 16:45:46 UTC (rev 188)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-23 18:34:10 UTC (rev 189)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './src/moul/qt/ui/mainwindow.ui'
#
-# Created: Fri Feb 23 05:05:02 2007
+# Created: Fri Feb 23 19:22:27 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -872,9 +872,9 @@
self.sb_fahrah_hahr = QtGui.QSpinBox(self.gridLayout_5)
self.sb_fahrah_hahr.setMaximumSize(QtCore.QSize(46,16777215))
- self.sb_fahrah_hahr.setMaximum(249)
+ self.sb_fahrah_hahr.setMaximum(624)
self.sb_fahrah_hahr.setMinimum(0)
- self.sb_fahrah_hahr.setProperty("value",QtCore.QVariant(87))
+ self.sb_fahrah_hahr.setProperty("value",QtCore.QVariant(287))
self.sb_fahrah_hahr.setObjectName("sb_fahrah_hahr")
self.hboxlayout11.addWidget(self.sb_fahrah_hahr)
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-23 16:45:46 UTC (rev 188)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-23 18:34:10 UTC (rev 189)
@@ -1872,13 +1872,13 @@
</size>
</property>
<property name="maximum" >
- <number>249</number>
+ <number>624</number>
</property>
<property name="minimum" >
<number>0</number>
</property>
<property name="value" >
- <number>87</number>
+ <number>287</number>
</property>
</widget>
</item>
Modified: pymoul/trunk/src/moul/qt/utils.py
===================================================================
--- pymoul/trunk/src/moul/qt/utils.py 2007-02-23 16:45:46 UTC (rev 188)
+++ pymoul/trunk/src/moul/qt/utils.py 2007-02-23 18:34:10 UTC (rev 189)
@@ -524,4 +524,4 @@
udt = normalizeTZ(UTC, dt)
qd = QtCore.QDate(udt.year, udt.month, udt.day)
qt = QtCore.QTime(udt.hour, udt.minute, udt.second)
- return QtCore.QDateTime(qd, qt, QtCore.Qt.UTC)
+ return QtCore.QDateTime(qd, qt, QtCore.Qt.UTC).toLocalTime()
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-23 16:45:46 UTC (rev 188)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-23 18:34:10 UTC (rev 189)
@@ -205,8 +205,10 @@
def set(self, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
gorahn=0, prorahn=0):
+ self._hahr = 0
+ self._prorahn = 0
+
self.hahr = hahr
- self._prorahn = 0
self.vailee = vailee
self.yahr = yahr
self.gahrtahvo = gahrtahvo
@@ -332,7 +334,7 @@
if addhahr:
self._hahr += addhahr
value = value - (addhahr * PRORAHN_PER_HAHR)
- self._prorahn = value
+ self._prorahn += value
def prorahnOfYahr(self):
"""Get numbers of prorahntee since start of yahr
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-24 19:45:38
|
Revision: 190
http://pymoul.svn.sourceforge.net/pymoul/?rev=190&view=rev
Author: tiran
Date: 2007-02-24 11:45:36 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
Ping tab changed to use QTableWidget
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/server/serverlist.py
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-23 18:34:10 UTC (rev 189)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-24 19:45:36 UTC (rev 190)
@@ -386,48 +386,80 @@
"""
init ping tab
"""
+ header = self.tw_ping.horizontalHeader()
+ header.setResizeMode(QtGui.QHeaderView.Fixed)
+ header.setResizeMode(0, QtGui.QHeaderView.Stretch)
+ self.tw_ping.setColumnCount(3)
+
self._ping_thread = thread = PingServerThread()
-
+
self.connect(thread, SIGNAL("started()"),
self.on_pingthread_started)
self.connect(thread, SIGNAL("finished()"),
self.on_pingthread_done)
- self.connect(thread, SIGNAL("server(const QString&)"),
+ self.connect(thread, SIGNAL("server(int, const QString&)"),
self.on_pingthread_server)
- self.connect(thread, SIGNAL("dnserror(const QString&, int, const QString&)"),
+ self.connect(thread, SIGNAL("dnserror(int, int, const QString &)"),
self.on_pingthread_dnserror)
- self.connect(thread, SIGNAL("dns(const QString&, float)"),
+ self.connect(thread, SIGNAL("dns(int, float)"),
self.on_pingthread_dns)
- self.connect(thread, SIGNAL("pingerror(const QString&, int, const QString&)"),
+ self.connect(thread, SIGNAL("pingerror(int, int, const QString &)"),
self.on_pingthread_pingerror)
- self.connect(thread, SIGNAL("ping(const QString&, float)"),
+ self.connect(thread, SIGNAL("ping(int, float)"),
self.on_pingthread_ping)
def on_pingthread_started(self):
self.button_ping.setEnabled(False)
- self.tb_ping_view.clear()
+ self.tw_ping.clearContents()
def on_pingthread_done(self):
self.button_ping.setEnabled(True)
- def on_pingthread_server(self, name):
- pass
- #self.tb_ping_view.insertPlainText("%s ... " % name)
+ def on_pingthread_server(self, i, name):
+ row = self.tw_ping.rowCount()
+ if row < (i+1):
+ self.tw_ping.setRowCount(i + 1)
- def on_pingthread_dns(self, name, time):
- self.tb_ping_view.insertPlainText("%s ... DNS: %0.3f " % (name, time))
+ proto = QtGui.QTableWidgetItem()
+ font = QtGui.QFont()
+ font.setPointSize(7)
+ proto.setFont(font)
+ proto.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- def on_pingthread_ping(self, name, time):
- self.tb_ping_view.insertPlainText("PING: %0.3f\n" % time)
+ header = QtGui.QTableWidgetItem(proto)
+ header.setText(QtCore.QString.number(row + 1))
- def on_pingthread_dnserror(self, name, errcode, errmsg):
- LOG.error('dns error: %s, %i, %s' % (name, errcode, errmsg))
- self.tb_ping_view.insertPlainText("%s ... DNS error: %s\n" % (name, errmsg))
+ item0 = QtGui.QTableWidgetItem(proto)
+ item0.setText(name)
- def on_pingthread_pingerror(self, name, errcode, errmsg):
- LOG.error('ping error: %s, %i, %s' % (name, errcode, errmsg))
- self.tb_ping_view.insertPlainText("PING error: %s\n" % errmsg)
+ self.tw_ping.setVerticalHeaderItem(i, header)
+ self.tw_ping.setItem(i, 0, item0)
+ self.tw_ping.setItem(i, 1, QtGui.QTableWidgetItem(proto))
+ self.tw_ping.setItem(i, 2, QtGui.QTableWidgetItem(proto))
+ self.tw_ping.resizeRowsToContents()
+ def on_pingthread_dns(self, i, time):
+ item = self.tw_ping.item(i, 1)
+ item.setText("%0.3f" % time)
+
+ def on_pingthread_ping(self, i, time):
+ item = self.tw_ping.item(i, 2)
+ item.setText("%0.3f" % time)
+
+ def on_pingthread_dnserror(self, i, errcode, errmsg):
+ item = self.tw_ping.item(i, 1)
+ item.setForeground(QtGui.QBrush(Qt.red))
+ item.setText(errmsg)
+ item.setToolTip("%s (code: %i)" % (errmsg, errcode))
+ #self.tw_ping.resizeColumnsToContents()
+
+ def on_pingthread_pingerror(self, i, errcode, errmsg):
+ item = self.tw_ping.item(i, 2)
+ item.setForeground(QtGui.QBrush(Qt.red))
+ item.setText(errmsg)
+ item.setToolTip("%s (code: %i)" % (errmsg, errcode))
+ #self.tw_ping.resizeColumnsToContents()
+
@pyqtSignature("bool")
def on_button_ping_clicked(self, ignore=False):
thread = self._ping_thread
@@ -451,26 +483,26 @@
def run(self):
# TODO: thread safety!
# emit a list of names first
- for server in self.servers:
- self.emit(SIGNAL("server(const QString&)"), server.name)
+ for i, server in enumerate(self.servers):
+ self.emit(SIGNAL("server(int, const QString&)"), i, server.name)
- for server in self.servers:
+ for i, server in enumerate(self.servers):
name = server.name
dns = server.dns()
if isSocketError(dns):
errno, msg = fmtSocketError(dns)
- self.emit(SIGNAL("dnserror(const QString&, int, const QString&)"),
- name, errno, msg)
+ self.emit(SIGNAL("dnserror(int, int, const QString &)"),
+ i, errno, msg)
continue
- self.emit(SIGNAL("dns(const QString&, float)"), name, dns)
+ self.emit(SIGNAL("dns(int, float)"), i, dns)
ping = server.portping()
if isSocketError(ping):
- errno, msg = fmtSocketError(dns)
- self.emit(SIGNAL("pingerror(const QString&, int, const QString&)"),
- name, errno, msg)
+ errno, msg = fmtSocketError(ping)
+ self.emit(SIGNAL("pingerror(int, int, const QString &)"),
+ i, errno, msg)
continue
- self.emit(SIGNAL("ping(const QString&, float)"), name, ping)
+ self.emit(SIGNAL("ping(int, float)"), i, ping)
class MoulRunningThread(QtCore.QThread):
def __init__(self, parent=None):
@@ -485,7 +517,7 @@
if not self.isRunning():
self._running = True
self.start()
-
+
def stopChecker(self):
# TODO check this
self._running = False
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-23 18:34:10 UTC (rev 189)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-02-24 19:45:36 UTC (rev 190)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './src/moul/qt/ui/mainwindow.ui'
#
-# Created: Fri Feb 23 19:22:27 2007
+# Created: Sat Feb 24 20:39:41 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -681,11 +681,9 @@
self.button_ping.setGeometry(QtCore.QRect(370,370,75,24))
self.button_ping.setObjectName("button_ping")
- self.tb_ping_view = QtGui.QTextBrowser(self.gb_servers)
- self.tb_ping_view.setGeometry(QtCore.QRect(10,20,431,341))
- self.tb_ping_view.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
- self.tb_ping_view.setOpenExternalLinks(True)
- self.tb_ping_view.setObjectName("tb_ping_view")
+ self.tw_ping = QtGui.QTableWidget(self.gb_servers)
+ self.tw_ping.setGeometry(QtCore.QRect(10,20,431,341))
+ self.tw_ping.setObjectName("tw_ping")
self.tabwidget.addTab(self.tab_ping,"")
self.tab_time = QtGui.QWidget()
@@ -1114,7 +1112,7 @@
self.lb_doc_status.setBuddy(self.pb_doc_loadjournals)
self.retranslateUi(MainWindow)
- self.tabwidget.setCurrentIndex(3)
+ self.tabwidget.setCurrentIndex(2)
self.tab_sub_settings.setCurrentIndex(0)
self.tabWidget.setCurrentIndex(0)
self.tabwidget_about.setCurrentIndex(0)
@@ -1175,6 +1173,21 @@
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_settings), QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
self.gb_servers.setTitle(QtGui.QApplication.translate("MainWindow", "Ping servers", None, QtGui.QApplication.UnicodeUTF8))
self.button_ping.setText(QtGui.QApplication.translate("MainWindow", "Ping", None, QtGui.QApplication.UnicodeUTF8))
+ self.tw_ping.clear()
+ self.tw_ping.setColumnCount(3)
+ self.tw_ping.setRowCount(0)
+
+ headerItem = QtGui.QTableWidgetItem()
+ headerItem.setText(QtGui.QApplication.translate("MainWindow", "Server", None, QtGui.QApplication.UnicodeUTF8))
+ self.tw_ping.setHorizontalHeaderItem(0,headerItem)
+
+ headerItem1 = QtGui.QTableWidgetItem()
+ headerItem1.setText(QtGui.QApplication.translate("MainWindow", "DNS", None, QtGui.QApplication.UnicodeUTF8))
+ self.tw_ping.setHorizontalHeaderItem(1,headerItem1)
+
+ headerItem2 = QtGui.QTableWidgetItem()
+ headerItem2.setText(QtGui.QApplication.translate("MainWindow", "Ping", None, QtGui.QApplication.UnicodeUTF8))
+ self.tw_ping.setHorizontalHeaderItem(2,headerItem2)
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_ping), QtGui.QApplication.translate("MainWindow", "Servers", None, QtGui.QApplication.UnicodeUTF8))
self.gb_dnitime.setTitle(QtGui.QApplication.translate("MainWindow", "D\'ni time", None, QtGui.QApplication.UnicodeUTF8))
self.gb_caverntime.setTitle(QtGui.QApplication.translate("MainWindow", "Time zones", None, QtGui.QApplication.UnicodeUTF8))
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-23 18:34:10 UTC (rev 189)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-02-24 19:45:36 UTC (rev 190)
@@ -110,7 +110,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex" >
- <number>3</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="tab_tasks" >
<attribute name="title" >
@@ -1464,7 +1464,7 @@
<string>Ping</string>
</property>
</widget>
- <widget class="QTextBrowser" name="tb_ping_view" >
+ <widget class="QTableWidget" name="tw_ping" >
<property name="geometry" >
<rect>
<x>10</x>
@@ -1473,12 +1473,21 @@
<height>341</height>
</rect>
</property>
- <property name="textInteractionFlags" >
- <enum>Qt::TextSelectableByMouse</enum>
- </property>
- <property name="openExternalLinks" >
- <bool>true</bool>
- </property>
+ <column>
+ <property name="text" >
+ <string>Server</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>DNS</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Ping</string>
+ </property>
+ </column>
</widget>
</widget>
</widget>
Modified: pymoul/trunk/src/moul/server/serverlist.py
===================================================================
--- pymoul/trunk/src/moul/server/serverlist.py 2007-02-23 18:34:10 UTC (rev 189)
+++ pymoul/trunk/src/moul/server/serverlist.py 2007-02-24 19:45:36 UTC (rev 190)
@@ -26,6 +26,8 @@
SERVER_LIST = [
'beta-auth.urulive.com',
'beta-file.urulive.com',
+ #'bogus.foo.bar',
+ #'www.mystonline.com',
'uruapp-cw01.ibs.aol.com',
'uruapp-cw02.ibs.aol.com',
'uruapp-cw03.ibs.aol.com',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-02-26 15:16:26
|
Revision: 193
http://pymoul.svn.sourceforge.net/pymoul/?rev=193&view=rev
Author: tiran
Date: 2007-02-26 07:16:22 -0800 (Mon, 26 Feb 2007)
Log Message:
-----------
Changed the way a DniTime object is constructed. It now uses several class methods as constructor
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/time/dni.py
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-26 15:05:28 UTC (rev 192)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-02-26 15:16:22 UTC (rev 193)
@@ -63,7 +63,6 @@
# D'ni numbers
self.dninumbers = QDniNumbers()
self.caverntime = CavernTime()
- self.dnitime = DniTime()
self.setup_dninumbers()
# D'ni date and time
@@ -137,10 +136,10 @@
"""
SIGNAL: QTimer timeout
"""
- self.dnitime.fromUTC()
- self.clockscene.setClockFromDniTime(self.dnitime)
- self.setWidgetDniTime(self.dnitime)
- self.dte_earthtime.setDateTime(dt2qdt(self.dnitime.toUTC()))
+ dni = DniTime.fromUTC()
+ self.clockscene.setClockFromDniTime(dni)
+ self.setWidgetDniTime(dni)
+ self.dte_earthtime.setDateTime(dt2qdt(dni.toUTC()))
@pyqtSignature("bool")
def on_rb_curtime_clicked(self, value):
@@ -189,6 +188,7 @@
self.update_dniholidays()
@pyqtSignature("const QDateTime &")
+ @skipLogging
def on_dte_earthtime_dateTimeChanged(self, qdt):
if self.rb_earthtime.isChecked():
self.update_earthtime()
@@ -198,17 +198,17 @@
"""
if not self.rb_dnitime.isChecked():
return
- self.dnitime.set(*self.getWidgetDniTime())
- self.clockscene.setClockFromDniTime(self.dnitime)
- self.dte_earthtime.setDateTime(dt2qdt(self.dnitime.toUTC()))
+ dni = DniTime.fromDni(*self.getWidgetDniTime())
+ self.clockscene.setClockFromDniTime(dni)
+ self.dte_earthtime.setDateTime(dt2qdt(dni.toUTC()))
def update_earthtime(self):
"""Update view from earth time widget
"""
dt = qdt2dt(self.dte_earthtime.dateTime())
- self.dnitime.fromUTC(dt)
- self.clockscene.setClockFromDniTime(self.dnitime)
- self.setWidgetDniTime(self.dnitime)
+ dni = DniTime.fromUTC(dt)
+ self.clockscene.setClockFromDniTime(dni)
+ self.setWidgetDniTime(dni)
def update_dniholidays(self):
"""Update view from D'ni holiday widget
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-02-26 15:05:28 UTC (rev 192)
+++ pymoul/trunk/src/moul/time/dni.py 2007-02-26 15:16:22 UTC (rev 193)
@@ -42,8 +42,7 @@
... else:
... return True
->>> dni = DniTime()
->>> dni.fromUTC(LEEFO_1_TABLE[1])
+>>> dni = DniTime.fromUTC(LEEFO_1_TABLE[1])
>>> dni.get()
(9655, 1, 1, 0, 0, 0, 0)
>>> str(dni)
@@ -52,7 +51,7 @@
True
>>> other = datetime(2007, 2, 12, 13, 55, 10, 0, tzinfo=UTC)
->>> dni.fromUTC(other)
+>>> dni = DniTime.fromUTC(other)
>>> dni.get()
(9662, 9, 4, 4, 21, 24, 22)
>>> str(dni)
@@ -69,13 +68,13 @@
80964
>>> CET = timezone('CET')
->>> dni.fromString("2007-02-12 14:55:10", tzinfo=CET)
+>>> dni = DniTime.fromString("2007-02-12 14:55:10", tzinfo=CET)
>>> str(dni)
'04:21:24:22, Leevotar 4, 9662'
->>> dni.fromString("2007-02-12 6:55:10", tzinfo='MST')
+>>> dni = DniTime.fromString("2007-02-12 6:55:10", tzinfo='MST')
>>> str(dni)
'04:21:24:22, Leevotar 4, 9662'
->>> dni.fromString("2007-02-12 13:55:10")
+>>> dni = DniTime.fromString("2007-02-12 13:55:10")
>>> str(dni)
'04:21:24:22, Leevotar 4, 9662'
@@ -199,46 +198,66 @@
prorahn second about 1.3929 seconds
"""
- def __init__(self, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
- gorahn=0, prorahn=0):
- self.set(hahr, vailee, yahr, gahrtahvo, tahvo, gorahn, prorahn)
-
- def set(self, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
- gorahn=0, prorahn=0):
+ def __init__(self, _initialize=False):
+ if not _initialize:
+ raise TypeError("You can't construct an instance this way!")
self._hahr = 0
self._prorahn = 0
- self.hahr = hahr
- self.vailee = vailee
- self.yahr = yahr
- self.gahrtahvo = gahrtahvo
- self.tahvo = tahvo
- self.gorahn = gorahn
- self._addProrahn(prorahn)
+ @classmethod
+ def fromDni(cls, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
+ gorahn=0, prorahn=0):
+ """Constructor from D'ni time
+ """
+ self = cls(_initialize=True)
+ self.set(hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
+ gorahn=0, prorahn=0)
+ return self
- def get(self):
- return (self.hahr, self.vailee, self.yahr, self.gahrtahvo, self.tahvo,
- self.gorahn, self.prorahn)
+ @classmethod
+ def fromUTC(cls, utc_dt=None):
+ """Constructor from UTC date time object
- def fromUTC(self, utc_dt=None):
- """Convert from UTC datetime
+ Convert from UTC datetime
"""
+ self = cls(_initialize=True)
if utc_dt is None:
utc_dt = utcnow()
sec = td2sec(utc_dt - BASE_GREGORIAN)
prorahn = int(round(sec * FACTOR_PS))
self.set(hahr=BASE_HAHR, prorahn=prorahn)
+ return self
- def fromString(self, s, fmt="%Y-%m-%d %H:%M:%S", tzinfo=UTC):
- """Convert date from string to Dni Time
+ @classmethod
+ def fromString(cls, s, fmt="%Y-%m-%d %H:%M:%S", tzinfo=UTC):
+ """Constructor from date time string
+
+ Convert date from string to Dni Time
"""
if isinstance(tzinfo, basestring):
tzinfo = timezone(tzinfo)
dt = datetime.strptime(s, fmt)
dt = tzinfo.localize(dt)
utc_dt = UTC.normalize(dt.astimezone(UTC))
- return self.fromUTC(utc_dt)
+ return cls.fromUTC(utc_dt)
+ def set(self, hahr=0, vailee=0, yahr=0, gahrtahvo=0, tahvo=0,
+ gorahn=0, prorahn=0):
+ self._hahr = 0
+ self._prorahn = 0
+
+ self.hahr = hahr
+ self.vailee = vailee
+ self.yahr = yahr
+ self.gahrtahvo = gahrtahvo
+ self.tahvo = tahvo
+ self.gorahn = gorahn
+ self._addProrahn(prorahn)
+
+ def get(self):
+ return (self.hahr, self.vailee, self.yahr, self.gahrtahvo, self.tahvo,
+ self.gorahn, self.prorahn)
+
def toUTC(self):
"""Convert to UTC datetime value
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-08 02:28:10
|
Revision: 241
http://pymoul.svn.sourceforge.net/pymoul/?rev=241&view=rev
Author: tiran
Date: 2007-03-07 18:28:11 -0800 (Wed, 07 Mar 2007)
Log Message:
-----------
Fixed name of Pahrtahvo
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/time/dni.py
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-03-08 02:12:19 UTC (rev 240)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-03-08 02:28:11 UTC (rev 241)
@@ -586,7 +586,7 @@
self._prorahn = dnitime._prorahn
#self.clocktext.setPlainText(str(dnitime))
- self.circle.setPahrtovo(dnitime.getPahrtovoFraction())
+ self.circle.setPahrtahvo(dnitime.getPahrtahvoFraction())
hahr = decimal2dni(dnitime.hahr, digits=3)
self.hahrl.setNumber(hahr[0])
@@ -615,15 +615,15 @@
def __init__(self, parent=None, scene=None):
QtGui.QGraphicsItem.__init__(self, parent, scene)
- self._pahrtovo = 0.0
+ self._Pahrtahvo = 0.0
self._dni = QDniNumbers()
def boundingRect(self):
return self.outrect
- def setPahrtovo(self, value):
- if value != self._pahrtovo:
- self._pahrtovo = value
+ def setPahrtahvo(self, value):
+ if value != self._Pahrtahvo:
+ self._Pahrtahvo = value
self.update()
def paint(self, painter, option, widget):
@@ -672,7 +672,7 @@
painter.restore()
# number
- pm = self._dni.get(self._pahrtovo, height=self.pm_height)
+ pm = self._dni.get(self._Pahrtahvo, height=self.pm_height)
w = pm.width()
posx, posy = self.center[0]-w/2.0, self.center[1]-25.0-self.pm_height
#painter.save()
@@ -688,7 +688,7 @@
pen.setWidthF(2.5)
pen.setCapStyle(Qt.RoundCap)
painter.setPen(pen)
- rot = self.angel * self._pahrtovo + self.offset
+ rot = self.angel * self._Pahrtahvo + self.offset
end = QtCore.QPointF(self.center[0] + (self.r-self.rdot) * math.cos(rot),
self.center[1] + (self.r-self.rdot) * math.sin(rot))
painter.drawLine(QtCore.QPointF(*self.center), end)
Modified: pymoul/trunk/src/moul/time/dni.py
===================================================================
--- pymoul/trunk/src/moul/time/dni.py 2007-03-08 02:12:19 UTC (rev 240)
+++ pymoul/trunk/src/moul/time/dni.py 2007-03-08 02:28:11 UTC (rev 241)
@@ -57,11 +57,11 @@
>>> compareDT(dni.toUTC(), other)
True
->>> dni.pahrtovo
+>>> dni.pahrtahvo
24
->>> dni.secondsToPahrtovo(25)
+>>> dni.secondsToPahrtahvo(25)
2616
->>> dni.secondsToPahrtovo(18)
+>>> dni.secondsToPahrtahvo(18)
80964
>>> dni = DniTime.fromDni(9655, 1, 1, 0, 0, 0, 0)
@@ -144,7 +144,7 @@
PRORAHN_PER_VAILEE = 2265625 # ~ 36 days, 25 * 25 * 25 * 5 * 29
PRORAHN_PER_YAHR = 78125 # ~30h 14min, 25 * 25 * 25 * 5
PRORAHN_PER_GAHRTAHVO = 15625 # ~6h 3min, 25 * 25 * 25
-PRORAHN_PER_PAHRTOVO = 3125 # ~74min, 25 * 25 * 5
+PRORAHN_PER_PAHRTAHVO = 3125 # ~74min, 25 * 25 * 5
PRORAHN_PER_TAHVO = 625 # ~14,5 min, 25 * 25
PRORAHN_PER_GORAHN = 25 # ~34,8 sec, 25
FACTOR_SP = float(SECONDS_PER_HAHR) / float(PRORAHN_PER_HAHR) # 1.39285737931
@@ -205,7 +205,7 @@
vailee month 10 per year
yahr day 29 per vailee, about 30h 14min
gahrtahvo section about 6h, 3min
- pahrtovo hour about 1h 14min
+ pahrtahvo hour about 1h 14min
tahvo quarter about 14,5min
gorahn minute 36 seconds
prorahn second about 1.3929 seconds
@@ -279,8 +279,8 @@
td = timedelta(days=0, seconds=hahr_sec + prorahn_sec)
return UTC.normalize(BASE_GREGORIAN + td)
- def secondsToPahrtovo(self, bell):
- """Calculate seconds until bell (pahr-to-vo)
+ def secondsToPahrtahvo(self, bell):
+ """Calculate seconds until bell (pahr-ah-vo)
"""
if bell < 1 or bell > 25:
raise ValueError("%s too large or small" % bell)
@@ -330,12 +330,12 @@
self._addProrahn(value * PRORAHN_PER_GAHRTAHVO)
gahrtahvo = property(_getGahrtahvo, _setGahrtahvo)
- def _getPahrtovo(self):
- return (self._prorahn // PRORAHN_PER_PAHRTOVO) % 25
- pahrtovo = property(_getPahrtovo)
+ def _getPahrtahvo(self):
+ return (self._prorahn // PRORAHN_PER_PAHRTAHVO) % 25
+ pahrtahvo = property(_getPahrtahvo)
- def getPahrtovoFraction(self):
- """Get Pahrtovo with decimal fraction
+ def getPahrtahvoFraction(self):
+ """Get Pahrtahvo with decimal fraction
"""
return ((self._prorahn // PRORAHN_PER_TAHVO) % 125) / 5.0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-15 08:43:34
|
Revision: 259
http://pymoul.svn.sourceforge.net/pymoul/?rev=259&view=rev
Author: tiran
Date: 2007-03-15 01:43:34 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
Unit test fixes
Fixed tab view order
Modified Paths:
--------------
pymoul/trunk/src/moul/osdependent/tests/test_singleapp.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
Modified: pymoul/trunk/src/moul/osdependent/tests/test_singleapp.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/tests/test_singleapp.py 2007-03-15 08:39:32 UTC (rev 258)
+++ pymoul/trunk/src/moul/osdependent/tests/test_singleapp.py 2007-03-15 08:43:34 UTC (rev 259)
@@ -37,7 +37,9 @@
from moul.osdependent.singleapp import unlock
if os.name == 'nt':
- rmcmd = "cmd /c del %(testfile)s"
+ rmcmd = (r'%(exe)s -c "import os; '
+ 'os.unlink(%(testfile)s)"' % {'exe' : sys.executable,
+ 'testfile' : r"'%(testfile)s'"})
else:
rmcmd = ("%(exe)s -c 'from fcntl import *; "
"fd = open(%(testfile)s, %(mode)s); "
@@ -61,22 +63,36 @@
#False
class SingleAppTest(unittest.TestCase):
+ def setUp(self):
+ hndl, tmpfile = tempfile.mkstemp()
+ self.tmpfile = os.path.normcase(tmpfile).replace('\\', '/')
+ os.close(hndl)
+ self.fd = open(self.tmpfile, mode='w+')
- def test_locking(self):
+ def tearDown(self):
+ try:
+ unlock(self.fd)
+ self.fd.close()
+ except:
+ pass
+ os.unlink(self.tmpfile)
+
+ def test_locking(self):
FLAGS = LOCK_SH | LOCK_NB
- fd = tempfile.NamedTemporaryFile(mode='w+', suffix='lck')
- testfile = fd.name
- fd.write('testdata')
- fd.flush()
- self.failUnless(os.path.isfile(testfile))
- lock(fd, FLAGS)
- popen = Popen(rmcmd % {'testfile' : testfile}, stdout=PIPE,
- stderr=PIPE, shell=True, env = {'LC_ALL' : 'C'})
-
+ self.fd.write('testdata')
+ self.fd.flush()
+ self.failUnless(os.path.isfile(self.tmpfile))
+ lock(self.fd, FLAGS)
+ env = os.environ.copy()
+ env['LC_ALL'] = 'C'
+ popen = Popen(rmcmd % {'testfile' : self.tmpfile}, stdout=PIPE,
+ stderr=PIPE, shell=True, env=env)
popen.wait()
+ self.failUnless(os.path.isfile(self.tmpfile))
+
out = popen.stdout.read()
if os.name == 'nt':
- self.failUnlessEqual(out, '')
+ self.failUnless(self.tmpfile in out or out == '', out)
elif os.name =='posix':
self.failUnlessEqual(out, '')
else:
@@ -84,16 +100,12 @@
err = popen.stderr.read()
if os.name == 'nt':
- self.failUnless('IOError: [Errno 11] Resource temporarily unavailable' in err, err)
+ self.failUnless('WindowsError: [Error 13]' in err, err)
elif os.name =='posix':
- self.failUnless('IOError: [Errno 11] Resource temporarily unavailable' in err, err)
+ self.failUnless('IOError: [Errno 11]' in err, err)
else:
raise OSError("unsupported os")
- self.failUnless(os.path.isfile(testfile))
- unlock(fd)
- fd.close()
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(SingleAppTest),
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-03-15 08:39:32 UTC (rev 258)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-03-15 08:43:34 UTC (rev 259)
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-# Form implementation generated from reading ui file 'src/moul/qt/ui/mainwindow.ui'
+# Form implementation generated from reading ui file 'src\moul\qt\ui\mainwindow.ui'
#
-# Created: Sat Mar 10 15:51:37 2007
+# Created: Thu Mar 15 09:09:39 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -959,11 +959,11 @@
self.groupBox_4.setGeometry(QtCore.QRect(10,0,451,371))
self.groupBox_4.setObjectName("groupBox_4")
- self.widget = QtGui.QWidget(self.groupBox_4)
- self.widget.setGeometry(QtCore.QRect(7,20,441,58))
- self.widget.setObjectName("widget")
+ self.layoutWidget4 = QtGui.QWidget(self.groupBox_4)
+ self.layoutWidget4.setGeometry(QtCore.QRect(7,20,441,58))
+ self.layoutWidget4.setObjectName("layoutWidget4")
- self.gridlayout3 = QtGui.QGridLayout(self.widget)
+ self.gridlayout3 = QtGui.QGridLayout(self.layoutWidget4)
self.gridlayout3.setMargin(0)
self.gridlayout3.setSpacing(6)
self.gridlayout3.setObjectName("gridlayout3")
@@ -971,39 +971,39 @@
spacerItem9 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
self.gridlayout3.addItem(spacerItem9,0,2,1,1)
- self.label_6 = QtGui.QLabel(self.widget)
+ self.label_6 = QtGui.QLabel(self.layoutWidget4)
self.label_6.setObjectName("label_6")
self.gridlayout3.addWidget(self.label_6,1,0,1,1)
- self.le_eg_status = QtGui.QLineEdit(self.widget)
+ self.le_eg_status = QtGui.QLineEdit(self.layoutWidget4)
self.le_eg_status.setReadOnly(True)
self.le_eg_status.setObjectName("le_eg_status")
self.gridlayout3.addWidget(self.le_eg_status,1,1,1,1)
- self.le_eg_length = QtGui.QLineEdit(self.widget)
+ self.le_eg_length = QtGui.QLineEdit(self.layoutWidget4)
self.le_eg_length.setReadOnly(True)
self.le_eg_length.setObjectName("le_eg_length")
self.gridlayout3.addWidget(self.le_eg_length,1,4,1,1)
- self.le_eg_light = QtGui.QLineEdit(self.widget)
+ self.le_eg_light = QtGui.QLineEdit(self.layoutWidget4)
self.le_eg_light.setReadOnly(True)
self.le_eg_light.setObjectName("le_eg_light")
self.gridlayout3.addWidget(self.le_eg_light,0,4,1,1)
- self.le_eg_time = QtGui.QLineEdit(self.widget)
+ self.le_eg_time = QtGui.QLineEdit(self.layoutWidget4)
self.le_eg_time.setReadOnly(True)
self.le_eg_time.setObjectName("le_eg_time")
self.gridlayout3.addWidget(self.le_eg_time,0,1,1,1)
- self.label_13 = QtGui.QLabel(self.widget)
+ self.label_13 = QtGui.QLabel(self.layoutWidget4)
self.label_13.setObjectName("label_13")
self.gridlayout3.addWidget(self.label_13,0,3,1,1)
- self.label_14 = QtGui.QLabel(self.widget)
+ self.label_14 = QtGui.QLabel(self.layoutWidget4)
self.label_14.setObjectName("label_14")
self.gridlayout3.addWidget(self.label_14,1,3,1,1)
- self.label_4 = QtGui.QLabel(self.widget)
+ self.label_4 = QtGui.QLabel(self.layoutWidget4)
self.label_4.setObjectName("label_4")
self.gridlayout3.addWidget(self.label_4,0,0,1,1)
@@ -1205,9 +1205,9 @@
self.lb_doc_status.setBuddy(self.pb_doc_loadjournals)
self.retranslateUi(MainWindow)
- self.tabwidget.setCurrentIndex(3)
+ self.tabwidget.setCurrentIndex(0)
self.tab_sub_settings.setCurrentIndex(1)
- self.tabWidget_2.setCurrentIndex(2)
+ self.tabWidget_2.setCurrentIndex(0)
self.tabWidget.setCurrentIndex(2)
self.tabwidget_about.setCurrentIndex(0)
QtCore.QObject.connect(self.main_buttonbox,QtCore.SIGNAL("rejected()"),MainWindow.close)
@@ -1335,8 +1335,8 @@
self.groupBox_5.setTitle(QtGui.QApplication.translate("MainWindow", "Read chatlogs", None, QtGui.QApplication.UnicodeUTF8))
self.tb_chatlog_view.setHtml(QtGui.QApplication.translate("MainWindow", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
- "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
- "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Not implemented</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
+ "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\">Not implemented</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.cb_chatlog.addItem(QtGui.QApplication.translate("MainWindow", "Not implemented", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_sub_chatlogs), QtGui.QApplication.translate("MainWindow", "Chat logs", None, QtGui.QApplication.UnicodeUTF8))
self.gb_documents.setTitle(QtGui.QApplication.translate("MainWindow", "Browse journals and notes", None, QtGui.QApplication.UnicodeUTF8))
@@ -1352,13 +1352,13 @@
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_browse), QtGui.QApplication.translate("MainWindow", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.tb_abouttext.setHtml(QtGui.QApplication.translate("MainWindow", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
- "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
- "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
+ "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget_about.setTabText(self.tabwidget_about.indexOf(self.tab_sub_about), QtGui.QApplication.translate("MainWindow", "About pyMoul", None, QtGui.QApplication.UnicodeUTF8))
self.tb_license.setHtml(QtGui.QApplication.translate("MainWindow", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
- "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
- "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
+ "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget_about.setTabText(self.tabwidget_about.indexOf(self.tab_sub_license), QtGui.QApplication.translate("MainWindow", "License", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_about), QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-03-15 08:39:32 UTC (rev 258)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-03-15 08:43:34 UTC (rev 259)
@@ -110,7 +110,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex" >
- <number>3</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="tab_tasks" >
<attribute name="title" >
@@ -1513,7 +1513,7 @@
</rect>
</property>
<property name="currentIndex" >
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="tab_time_dni" >
<attribute name="title" >
@@ -2080,7 +2080,7 @@
<property name="title" >
<string>Eder Gira day cycle</string>
</property>
- <widget class="QWidget" name="" >
+ <widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>7</x>
@@ -2320,8 +2320,8 @@
<property name="html" >
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Not implemented</p></body></html></string>
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;">Not implemented</p></body></html></string>
</property>
<property name="textInteractionFlags" >
<enum>Qt::TextSelectableByMouse</enum>
@@ -2564,8 +2564,8 @@
<property name="html" >
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html></string>
</property>
<property name="textInteractionFlags" >
<enum>Qt::TextBrowserInteraction</enum>
@@ -2591,8 +2591,8 @@
<property name="html" >
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html></string>
</property>
<property name="textInteractionFlags" >
<enum>Qt::TextSelectableByMouse</enum>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-19 09:35:03
|
Revision: 264
http://pymoul.svn.sourceforge.net/pymoul/?rev=264&view=rev
Author: tiran
Date: 2007-03-19 02:10:53 -0700 (Mon, 19 Mar 2007)
Log Message:
-----------
Integration of Eder Gira and Pod age times in the UI
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/qt/i18n/pymoul_de.ts
pymoul/trunk/src/moul/qt/i18n/pymoul_es.ts
pymoul/trunk/src/moul/qt/i18n/pymoul_fr.ts
pymoul/trunk/src/moul/qt/i18n/pymoul_it.ts
pymoul/trunk/src/moul/qt/i18n/pymoul_nl.ts
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/time/edergira.py
pymoul/trunk/src/moul/time/podage.py
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-03-19 09:10:53 UTC (rev 264)
@@ -17,6 +17,9 @@
#
"""Moul QT D'ni Number renderer
+
+This module started as a renderer for D'ni numbers and turned into a
+time display module 8-)
"""
__author__ = "Christian Heimes"
__version__ = "$Id$"
@@ -39,6 +42,9 @@
from moul.time.dni import FACTOR_SP
from moul.time.dni import VAILEETEE
from moul.time.dni import decimal2dni
+from moul.time.edergira import EderGiraDayCalculator
+from moul.time.podage import PodAgeTime
+from moul.time.podage import listPodAges
from moul.time.utils import utcnow
from moul.qt.utils import QNamespaceContainer
@@ -108,6 +114,104 @@
# setup defaults
self.rb_earthtime.click()
+ # pod age timers
+ self.minute_timer = QtCore.QTimer(self.context)
+ self.minute_timer.setInterval(60000) # 1 minute
+ self.connect(self.minute_timer, SIGNAL('timeout()'),
+ self.on_podage_timeout)
+ header = self.tw_pods.horizontalHeader()
+ header.setResizeMode(QtGui.QHeaderView.Stretch)
+
+ # Eder Gira day cycle timer
+ header = self.tw_eg.horizontalHeader()
+ header.setResizeMode(QtGui.QHeaderView.Stretch)
+ self.connect(self.minute_timer, SIGNAL('timeout()'),
+ self.on_edergira_timeout)
+ self.minute_timer.start()
+ self.minute_timer.emit(SIGNAL('timeout()'))
+
+ def _fmtdate(self, dt, spec=Qt.LocalTime):
+ fmt = self.trUtf8("MMM dd, hh:mm:ss")
+ qdt = QtCore.QDateTime(dt).toTimeSpec(spec)
+ return qdt.toString(fmt)
+
+ @skipLogging
+ @pyqtSignature("")
+ def on_edergira_timeout(self):
+ """
+ SIGNAL: QTimer timeout
+ """
+ rows = 5
+ eg = EderGiraDayCalculator()
+
+ tw = self.tw_eg
+ tw.clearContents()
+ tw.setRowCount(rows)
+
+ proto = QtGui.QTableWidgetItem()
+ #font = QtGui.QFont()
+ #font.setPointSize(7)
+ #proto.setFont(font)
+ proto.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
+ header = QtGui.QTableWidgetItem()
+ header.setSizeHint(QtCore.QSize(0,0))
+
+ for n, midnight, dawn, dusk in iter(eg):
+ if n > rows:
+ break
+ tw.setVerticalHeaderItem(n, QtGui.QTableWidgetItem(header))
+ for i, dt in enumerate((midnight, dawn, dusk)):
+ item = QtGui.QTableWidgetItem(proto)
+ item.setText(self._fmtdate(dt))
+ tw.setItem(n, i, item)
+
+ tw.resizeRowsToContents()
+
+ day = eg.getDayInfo()
+ self.le_eg_time.setText(str(day.hour))
+ self.le_eg_status.setText(str(day.state))
+ self.le_eg_light.setText("%i%%" % (day.light * 100))
+ self.le_eg_length.setText(self.trUtf8("10 hours"))
+
+ @skipLogging
+ @pyqtSignature("")
+ def on_podage_timeout(self):
+ """
+ SIGNAL: QTimer timeout
+ """
+ rows = 5
+ cols = len(listPodAges())
+
+ tw = self.tw_pods
+ tw.clearContents()
+ tw.setRowCount(rows)
+ tw.setColumnCount(cols)
+
+ proto = QtGui.QTableWidgetItem()
+ #font = QtGui.QFont()
+ #font.setPointSize(7)
+ #proto.setFont(font)
+ proto.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
+
+ for n in range(rows):
+ h = QtGui.QTableWidgetItem()
+ h.setSizeHint(QtCore.QSize(0,0))
+ tw.setVerticalHeaderItem(n, h)
+
+ for i, name in enumerate(listPodAges()):
+ pat = PodAgeTime(name)
+ hheader = QtGui.QTableWidgetItem()
+ hheader.setText(name)
+ tw.setHorizontalHeaderItem(i, hheader)
+ for n, dt in iter(pat):
+ if n > rows:
+ break
+ item = QtGui.QTableWidgetItem(proto)
+ item.setText(self._fmtdate(dt))
+ tw.setItem(n, i, item)
+
+ tw.resizeRowsToContents()
+
@pyqtSignature("bool")
def on_timer_timerEnable(self, value=True):
value = bool(value)
@@ -194,7 +298,7 @@
self.update_earthtime()
@pyqtSignature("int")
- def on_cb_earthtime_tz_currentIndeChanged(self, idx):
+ def on_cb_earthtime_tz_currentIndexChanged(self, idx):
if idx == 0:
spec = Qt.LoalTime
elif idx == 1:
Modified: pymoul/trunk/src/moul/qt/i18n/pymoul_de.ts
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/pymoul_de.ts 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/i18n/pymoul_de.ts 2007-03-19 09:10:53 UTC (rev 264)
@@ -5,6 +5,14 @@
<source>cyclic 0</source>
<translation>zyklische 0</translation>
</message>
+ <message>
+ <source>MMM dd, hh:mm:ss</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>10 hours</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>IniFileContainer</name>
@@ -520,17 +528,13 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn</source>
+ <source>Pod Ages</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn Gate appearence</source>
+ <source>Gate appearence</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <source>Gate</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>SimpleProgressbar</name>
Modified: pymoul/trunk/src/moul/qt/i18n/pymoul_es.ts
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/pymoul_es.ts 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/i18n/pymoul_es.ts 2007-03-19 09:10:53 UTC (rev 264)
@@ -5,6 +5,14 @@
<source>cyclic 0</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>MMM dd, hh:mm:ss</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>10 hours</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>IniFileContainer</name>
@@ -506,17 +514,13 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn</source>
+ <source>Pod Ages</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn Gate appearence</source>
+ <source>Gate appearence</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <source>Gate</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>SimpleProgressbar</name>
Modified: pymoul/trunk/src/moul/qt/i18n/pymoul_fr.ts
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/pymoul_fr.ts 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/i18n/pymoul_fr.ts 2007-03-19 09:10:53 UTC (rev 264)
@@ -5,6 +5,14 @@
<source>cyclic 0</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>MMM dd, hh:mm:ss</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>10 hours</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>IniFileContainer</name>
@@ -506,17 +514,13 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn</source>
+ <source>Pod Ages</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn Gate appearence</source>
+ <source>Gate appearence</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <source>Gate</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>SimpleProgressbar</name>
Modified: pymoul/trunk/src/moul/qt/i18n/pymoul_it.ts
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/pymoul_it.ts 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/i18n/pymoul_it.ts 2007-03-19 09:10:53 UTC (rev 264)
@@ -5,6 +5,14 @@
<source>cyclic 0</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>MMM dd, hh:mm:ss</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>10 hours</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>IniFileContainer</name>
@@ -506,17 +514,13 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn</source>
+ <source>Pod Ages</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn Gate appearence</source>
+ <source>Gate appearence</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <source>Gate</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>SimpleProgressbar</name>
Modified: pymoul/trunk/src/moul/qt/i18n/pymoul_nl.ts
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/pymoul_nl.ts 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/i18n/pymoul_nl.ts 2007-03-19 09:10:53 UTC (rev 264)
@@ -5,6 +5,14 @@
<source>cyclic 0</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>MMM dd, hh:mm:ss</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>10 hours</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>IniFileContainer</name>
@@ -506,17 +514,13 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn</source>
+ <source>Pod Ages</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Negilahn Gate appearence</source>
+ <source>Gate appearence</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <source>Gate</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>SimpleProgressbar</name>
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-03-19 09:10:53 UTC (rev 264)
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-# Form implementation generated from reading ui file 'src\moul\qt\ui\mainwindow.ui'
+# Form implementation generated from reading ui file 'src/moul/qt/ui/mainwindow.ui'
#
-# Created: Thu Mar 15 09:09:39 2007
+# Created: Mon Mar 19 10:09:02 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -524,6 +524,15 @@
self.cb_aud_eax.setGeometry(QtCore.QRect(20,20,191,22))
self.cb_aud_eax.setObjectName("cb_aud_eax")
+ self.groupBox_voicechat = QtGui.QGroupBox(self.tab_audio)
+ self.groupBox_voicechat.setEnabled(True)
+ self.groupBox_voicechat.setGeometry(QtCore.QRect(10,190,451,51))
+ self.groupBox_voicechat.setObjectName("groupBox_voicechat")
+
+ self.cb_aud_voicechat = QtGui.QCheckBox(self.groupBox_voicechat)
+ self.cb_aud_voicechat.setGeometry(QtCore.QRect(20,20,171,19))
+ self.cb_aud_voicechat.setObjectName("cb_aud_voicechat")
+
self.groupBox_aud_level = QtGui.QGroupBox(self.tab_audio)
self.groupBox_aud_level.setEnabled(True)
self.groupBox_aud_level.setGeometry(QtCore.QRect(10,0,451,181))
@@ -658,15 +667,6 @@
self.cb_aud_mute = QtGui.QCheckBox(self.groupBox_aud_level)
self.cb_aud_mute.setGeometry(QtCore.QRect(20,20,189,22))
self.cb_aud_mute.setObjectName("cb_aud_mute")
-
- self.groupBox_voicechat = QtGui.QGroupBox(self.tab_audio)
- self.groupBox_voicechat.setEnabled(True)
- self.groupBox_voicechat.setGeometry(QtCore.QRect(10,190,451,51))
- self.groupBox_voicechat.setObjectName("groupBox_voicechat")
-
- self.cb_aud_voicechat = QtGui.QCheckBox(self.groupBox_voicechat)
- self.cb_aud_voicechat.setGeometry(QtCore.QRect(20,20,171,19))
- self.cb_aud_voicechat.setObjectName("cb_aud_voicechat")
self.tab_sub_settings.addTab(self.tab_audio,"")
self.tabwidget.addTab(self.tab_settings,"")
@@ -694,9 +694,9 @@
self.tab_time = QtGui.QWidget()
self.tab_time.setObjectName("tab_time")
- self.tabWidget_2 = QtGui.QTabWidget(self.tab_time)
- self.tabWidget_2.setGeometry(QtCore.QRect(0,0,471,411))
- self.tabWidget_2.setObjectName("tabWidget_2")
+ self.tab_sub_time = QtGui.QTabWidget(self.tab_time)
+ self.tab_sub_time.setGeometry(QtCore.QRect(0,0,471,411))
+ self.tab_sub_time.setObjectName("tab_sub_time")
self.tab_time_dni = QtGui.QWidget()
self.tab_time_dni.setObjectName("tab_time_dni")
@@ -950,7 +950,7 @@
self.rb_dnitime = QtGui.QRadioButton(self.gridLayout_5)
self.rb_dnitime.setObjectName("rb_dnitime")
self.gridlayout2.addWidget(self.rb_dnitime,2,0,1,1)
- self.tabWidget_2.addTab(self.tab_time_dni,"")
+ self.tab_sub_time.addTab(self.tab_time_dni,"")
self.tab_time_eder = QtGui.QWidget()
self.tab_time_eder.setObjectName("tab_time_eder")
@@ -1011,7 +1011,7 @@
self.gridlayout3.addItem(spacerItem10,0,5,1,1)
self.tw_eg = QtGui.QTableWidget(self.groupBox_4)
- self.tw_eg.setGeometry(QtCore.QRect(10,90,431,141))
+ self.tw_eg.setGeometry(QtCore.QRect(10,90,431,131))
font = QtGui.QFont(self.tw_eg.font())
font.setPointSize(8)
@@ -1020,8 +1020,13 @@
self.tw_eg.setDragDropOverwriteMode(False)
self.tw_eg.setAlternatingRowColors(True)
self.tw_eg.setObjectName("tw_eg")
- self.tabWidget_2.addTab(self.tab_time_eder,"")
+ self.lb_localtime = QtGui.QLabel(self.groupBox_4)
+ self.lb_localtime.setGeometry(QtCore.QRect(360,230,81,20))
+ self.lb_localtime.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
+ self.lb_localtime.setObjectName("lb_localtime")
+ self.tab_sub_time.addTab(self.tab_time_eder,"")
+
self.tab_time_podages = QtGui.QWidget()
self.tab_time_podages.setObjectName("tab_time_podages")
@@ -1030,17 +1035,22 @@
self.groupBox_6.setGeometry(QtCore.QRect(10,0,451,371))
self.groupBox_6.setObjectName("groupBox_6")
- self.tw_eg_2 = QtGui.QTableWidget(self.groupBox_6)
- self.tw_eg_2.setGeometry(QtCore.QRect(10,30,431,141))
+ self.tw_pods = QtGui.QTableWidget(self.groupBox_6)
+ self.tw_pods.setGeometry(QtCore.QRect(10,30,431,131))
- font = QtGui.QFont(self.tw_eg_2.font())
+ font = QtGui.QFont(self.tw_pods.font())
font.setPointSize(8)
- self.tw_eg_2.setFont(font)
- self.tw_eg_2.setProperty("showDropIndicator",QtCore.QVariant(False))
- self.tw_eg_2.setDragDropOverwriteMode(False)
- self.tw_eg_2.setAlternatingRowColors(True)
- self.tw_eg_2.setObjectName("tw_eg_2")
- self.tabWidget_2.addTab(self.tab_time_podages,"")
+ self.tw_pods.setFont(font)
+ self.tw_pods.setProperty("showDropIndicator",QtCore.QVariant(False))
+ self.tw_pods.setDragDropOverwriteMode(False)
+ self.tw_pods.setAlternatingRowColors(True)
+ self.tw_pods.setObjectName("tw_pods")
+
+ self.lb_localtime_2 = QtGui.QLabel(self.groupBox_6)
+ self.lb_localtime_2.setGeometry(QtCore.QRect(360,170,81,20))
+ self.lb_localtime_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
+ self.lb_localtime_2.setObjectName("lb_localtime_2")
+ self.tab_sub_time.addTab(self.tab_time_podages,"")
self.tabwidget.addTab(self.tab_time,"")
self.tab_browse = QtGui.QWidget()
@@ -1206,8 +1216,8 @@
self.retranslateUi(MainWindow)
self.tabwidget.setCurrentIndex(0)
- self.tab_sub_settings.setCurrentIndex(1)
- self.tabWidget_2.setCurrentIndex(0)
+ self.tab_sub_settings.setCurrentIndex(0)
+ self.tab_sub_time.setCurrentIndex(0)
self.tabWidget.setCurrentIndex(2)
self.tabwidget_about.setCurrentIndex(0)
QtCore.QObject.connect(self.main_buttonbox,QtCore.SIGNAL("rejected()"),MainWindow.close)
@@ -1255,14 +1265,14 @@
self.lb_aud_device.setText(QtGui.QApplication.translate("MainWindow", "Generic Software", None, QtGui.QApplication.UnicodeUTF8))
self.lb_aud_priority.setText(QtGui.QApplication.translate("MainWindow", "Sound priority", None, QtGui.QApplication.UnicodeUTF8))
self.cb_aud_eax.setText(QtGui.QApplication.translate("MainWindow", "Enable EAX", None, QtGui.QApplication.UnicodeUTF8))
+ self.groupBox_voicechat.setTitle(QtGui.QApplication.translate("MainWindow", "Voice chat", None, QtGui.QApplication.UnicodeUTF8))
+ self.cb_aud_voicechat.setText(QtGui.QApplication.translate("MainWindow", "Enable Voice Chat", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_aud_level.setTitle(QtGui.QApplication.translate("MainWindow", "Level", None, QtGui.QApplication.UnicodeUTF8))
self.lb_aud_fx_3.setText(QtGui.QApplication.translate("MainWindow", "Sound FX", None, QtGui.QApplication.UnicodeUTF8))
self.lb_aud_music.setText(QtGui.QApplication.translate("MainWindow", "Music", None, QtGui.QApplication.UnicodeUTF8))
self.lb_aud_ambience.setText(QtGui.QApplication.translate("MainWindow", "Ambience Sound", None, QtGui.QApplication.UnicodeUTF8))
self.lb_aud_npc.setText(QtGui.QApplication.translate("MainWindow", "NPC Voices", None, QtGui.QApplication.UnicodeUTF8))
self.cb_aud_mute.setText(QtGui.QApplication.translate("MainWindow", "Mute all", None, QtGui.QApplication.UnicodeUTF8))
- self.groupBox_voicechat.setTitle(QtGui.QApplication.translate("MainWindow", "Voice chat", None, QtGui.QApplication.UnicodeUTF8))
- self.cb_aud_voicechat.setText(QtGui.QApplication.translate("MainWindow", "Enable Voice Chat", None, QtGui.QApplication.UnicodeUTF8))
self.tab_sub_settings.setTabText(self.tab_sub_settings.indexOf(self.tab_audio), QtGui.QApplication.translate("MainWindow", "Audio", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_settings), QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
self.gb_servers.setTitle(QtGui.QApplication.translate("MainWindow", "Ping servers", None, QtGui.QApplication.UnicodeUTF8))
@@ -1300,7 +1310,7 @@
self.cb_earthtime_tz.addItem(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
self.cb_earthtime_tz.addItem(QtGui.QApplication.translate("MainWindow", "UTC", None, QtGui.QApplication.UnicodeUTF8))
self.rb_dnitime.setText(QtGui.QApplication.translate("MainWindow", "D\'ni Time", None, QtGui.QApplication.UnicodeUTF8))
- self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_time_dni), QtGui.QApplication.translate("MainWindow", "D\'ni Time", None, QtGui.QApplication.UnicodeUTF8))
+ self.tab_sub_time.setTabText(self.tab_sub_time.indexOf(self.tab_time_dni), QtGui.QApplication.translate("MainWindow", "D\'ni Time", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_4.setTitle(QtGui.QApplication.translate("MainWindow", "Eder Gira day cycle", None, QtGui.QApplication.UnicodeUTF8))
self.label_6.setText(QtGui.QApplication.translate("MainWindow", "Sun", None, QtGui.QApplication.UnicodeUTF8))
self.label_13.setText(QtGui.QApplication.translate("MainWindow", "Light level", None, QtGui.QApplication.UnicodeUTF8))
@@ -1321,22 +1331,20 @@
headerItem5 = QtGui.QTableWidgetItem()
headerItem5.setText(QtGui.QApplication.translate("MainWindow", "Dusk", None, QtGui.QApplication.UnicodeUTF8))
self.tw_eg.setHorizontalHeaderItem(2,headerItem5)
- self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_time_eder), QtGui.QApplication.translate("MainWindow", "Eder Gira", None, QtGui.QApplication.UnicodeUTF8))
- self.groupBox_6.setTitle(QtGui.QApplication.translate("MainWindow", "Negilahn Gate appearence", None, QtGui.QApplication.UnicodeUTF8))
- self.tw_eg_2.clear()
- self.tw_eg_2.setColumnCount(1)
- self.tw_eg_2.setRowCount(0)
-
- headerItem6 = QtGui.QTableWidgetItem()
- headerItem6.setText(QtGui.QApplication.translate("MainWindow", "Gate", None, QtGui.QApplication.UnicodeUTF8))
- self.tw_eg_2.setHorizontalHeaderItem(0,headerItem6)
- self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_time_podages), QtGui.QApplication.translate("MainWindow", "Negilahn", None, QtGui.QApplication.UnicodeUTF8))
+ self.lb_localtime.setText(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
+ self.tab_sub_time.setTabText(self.tab_sub_time.indexOf(self.tab_time_eder), QtGui.QApplication.translate("MainWindow", "Eder Gira", None, QtGui.QApplication.UnicodeUTF8))
+ self.groupBox_6.setTitle(QtGui.QApplication.translate("MainWindow", "Gate appearence", None, QtGui.QApplication.UnicodeUTF8))
+ self.tw_pods.clear()
+ self.tw_pods.setColumnCount(0)
+ self.tw_pods.setRowCount(0)
+ self.lb_localtime_2.setText(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
+ self.tab_sub_time.setTabText(self.tab_sub_time.indexOf(self.tab_time_podages), QtGui.QApplication.translate("MainWindow", "Pod Ages", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_time), QtGui.QApplication.translate("MainWindow", "Time", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_5.setTitle(QtGui.QApplication.translate("MainWindow", "Read chatlogs", None, QtGui.QApplication.UnicodeUTF8))
self.tb_chatlog_view.setHtml(QtGui.QApplication.translate("MainWindow", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
- "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
- "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\">Not implemented</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
+ "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Not implemented</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.cb_chatlog.addItem(QtGui.QApplication.translate("MainWindow", "Not implemented", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_sub_chatlogs), QtGui.QApplication.translate("MainWindow", "Chat logs", None, QtGui.QApplication.UnicodeUTF8))
self.gb_documents.setTitle(QtGui.QApplication.translate("MainWindow", "Browse journals and notes", None, QtGui.QApplication.UnicodeUTF8))
@@ -1352,13 +1360,13 @@
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_browse), QtGui.QApplication.translate("MainWindow", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.tb_abouttext.setHtml(QtGui.QApplication.translate("MainWindow", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
- "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
- "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
+ "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget_about.setTabText(self.tabwidget_about.indexOf(self.tab_sub_about), QtGui.QApplication.translate("MainWindow", "About pyMoul", None, QtGui.QApplication.UnicodeUTF8))
self.tb_license.setHtml(QtGui.QApplication.translate("MainWindow", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
- "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
- "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Sans Serif\'; font-size:9pt;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ "</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">\n"
+ "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget_about.setTabText(self.tabwidget_about.indexOf(self.tab_sub_license), QtGui.QApplication.translate("MainWindow", "License", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_about), QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-03-18 22:50:45 UTC (rev 263)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-03-19 09:10:53 UTC (rev 264)
@@ -358,7 +358,7 @@
</rect>
</property>
<property name="currentIndex" >
- <number>1</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="tab_graphics" >
<attribute name="title" >
@@ -1126,6 +1126,35 @@
</property>
</widget>
</widget>
+ <widget class="QGroupBox" name="groupBox_voicechat" >
+ <property name="enabled" >
+ <bool>true</bool>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>190</y>
+ <width>451</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>Voice chat</string>
+ </property>
+ <widget class="QCheckBox" name="cb_aud_voicechat" >
+ <property name="geometry" >
+ <rect>
+ <x>20</x>
+ <y>20</y>
+ <width>171</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Enable Voice Chat</string>
+ </property>
+ </widget>
+ </widget>
<widget class="QGroupBox" name="groupBox_aud_level" >
<property name="enabled" >
<bool>true</bool>
@@ -1403,35 +1432,6 @@
</property>
</widget>
</widget>
- <widget class="QGroupBox" name="groupBox_voicechat" >
- <property name="enabled" >
- <bool>true</bool>
- </property>
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>190</y>
- <width>451</width>
- <height>51</height>
- </rect>
- </property>
- <property name="title" >
- <string>Voice chat</string>
- </property>
- <widget class="QCheckBox" name="cb_aud_voicechat" >
- <property name="geometry" >
- <rect>
- <x>20</x>
- <y>20</y>
- <width>171</wid...
[truncated message content] |
|
From: <ti...@us...> - 2007-03-19 16:39:56
|
Revision: 266
http://pymoul.svn.sourceforge.net/pymoul/?rev=266&view=rev
Author: tiran
Date: 2007-03-19 06:35:53 -0700 (Mon, 19 Mar 2007)
Log Message:
-----------
Corrected some paths (Linux and Mac)
Adjusted font sizes of table items
Modified Paths:
--------------
pymoul/trunk/src/moul/osdependent/darwin/__init__.py
pymoul/trunk/src/moul/osdependent/linux/__init__.py
pymoul/trunk/src/moul/qt/dninumbers.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
Modified: pymoul/trunk/src/moul/osdependent/darwin/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/darwin/__init__.py 2007-03-19 09:19:33 UTC (rev 265)
+++ pymoul/trunk/src/moul/osdependent/darwin/__init__.py 2007-03-19 13:35:53 UTC (rev 266)
@@ -31,7 +31,7 @@
LOG.critical('Darwin/Mac support is not tested')
HOME = os.path.expanduser('~')
-MOUL_DIR = "Library/Preferences/UruLive Preferences/p_drive/My Documents/Uru Live"
+MOUL_DIR = "%s/Library/Preferences/UruLive/Preferences/p_drive/My Documents/Uru Live" % HOME
APP_PATH = "Uru Live.app/Contents/Resources/Game.app/Contents/Resources/transgaming/c_drive/Program Files/Uru Live/"
APP_NAME = "Uru Live.app"
EXEC_NAME = "???" # XXX
@@ -40,7 +40,7 @@
"/Applications",
"%s/Applications" % HOME,
]
-PYMOUL_DIR = "Library/Preferences/pyMoul"
+PYMOUL_DIR = "%s/Library/Preferences/pyMoul" % HOME
def getMoulUserDataDir():
"""Get path of MOUL data directory
@@ -48,12 +48,12 @@
The MOUL data directory contains log files, chatlogs, KI images and many
more things.
"""
- return os.path.join(HOME, MOUL_DIR)
+ return MOUL_DIR
def getPyMoulDataDir():
"""Get path to the pyMoul ini directory
"""
- return os.path.join(HOME, PYMOUL_DIR)
+ return HOME, PYMOUL_DIR
def getMoulInstallDir():
"""Get path to MOUL install dir
Modified: pymoul/trunk/src/moul/osdependent/linux/__init__.py
===================================================================
--- pymoul/trunk/src/moul/osdependent/linux/__init__.py 2007-03-19 09:19:33 UTC (rev 265)
+++ pymoul/trunk/src/moul/osdependent/linux/__init__.py 2007-03-19 13:35:53 UTC (rev 266)
@@ -31,7 +31,7 @@
LOG.critical('Linux support is not tested')
HOME = os.path.expanduser('~')
-MOUL_DIR = ".urulive"
+MOUL_DIR = "%s/.urulive" % HOME
INI_FILE = ('pyMoul', 'pymoul.ini')
EXEC_NAME = "UruLauncher"
PROCESSES = ('urulauncher', 'uruexplorer')
@@ -40,7 +40,7 @@
"/media/d/games/MystOnline",
"/usr/local/games/MystOnline"
]
-PYMOUL_DIR = '.pymoul'
+PYMOUL_DIR = '%s/.pymoul' % HOME
def getMoulUserDataDir():
"""Get path of MOUL data directory
@@ -48,12 +48,12 @@
The MOUL data directory contains log files, chatlogs, KI images and many
more things.
"""
- return os.path.join(HOME, MOUL_DIR)
+ return MOUL_DIR
def getPyMoulDataDir():
"""Get path to the pyMoul ini directory
"""
- return os.path.join(HOME, PYMOUL_DIR)
+ return PYMOUL_DIR
def getMoulInstallDir():
"""Get path to MOUL install dir
Modified: pymoul/trunk/src/moul/qt/dninumbers.py
===================================================================
--- pymoul/trunk/src/moul/qt/dninumbers.py 2007-03-19 09:19:33 UTC (rev 265)
+++ pymoul/trunk/src/moul/qt/dninumbers.py 2007-03-19 13:35:53 UTC (rev 266)
@@ -131,7 +131,7 @@
self.minute_timer.emit(SIGNAL('timeout()'))
def _fmtdate(self, dt, spec=Qt.LocalTime):
- fmt = self.trUtf8("MMM dd, hh:mm:ss")
+ fmt = self.trUtf8("MM/dd hh:mm")
qdt = QtCore.QDateTime(dt).toTimeSpec(spec)
return qdt.toString(fmt)
@@ -149,17 +149,17 @@
tw.setRowCount(rows)
proto = QtGui.QTableWidgetItem()
- #font = QtGui.QFont()
- #font.setPointSize(7)
- #proto.setFont(font)
+ font = QtGui.QFont()
+ font.setPointSize(9)
+ proto.setFont(font)
proto.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- header = QtGui.QTableWidgetItem()
- header.setSizeHint(QtCore.QSize(0,0))
for n, midnight, dawn, dusk in iter(eg):
if n > rows:
break
- tw.setVerticalHeaderItem(n, QtGui.QTableWidgetItem(header))
+ #header = QtGui.QTableWidgetItem()
+ #header.setSizeHint(QtCore.QSize(0,0))
+ #tw.setVerticalHeaderItem(n, header)
for i, dt in enumerate((midnight, dawn, dusk)):
item = QtGui.QTableWidgetItem(proto)
item.setText(self._fmtdate(dt))
@@ -188,15 +188,14 @@
tw.setColumnCount(cols)
proto = QtGui.QTableWidgetItem()
- #font = QtGui.QFont()
- #font.setPointSize(7)
- #proto.setFont(font)
+ font = QtGui.QFont()
+ font.setPointSize(9)
+ proto.setFont(font)
proto.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- for n in range(rows):
- h = QtGui.QTableWidgetItem()
- h.setSizeHint(QtCore.QSize(0,0))
- tw.setVerticalHeaderItem(n, h)
+ #for n in range(rows):
+ # tw.setVerticalHeaderItem(n, QtGui.QTableWidgetItem())
+ # tw.verticalHeaderItem(n).setSizeHint(QtCore.QSize(0, 0))
for i, name in enumerate(listPodAges()):
pat = PodAgeTime(name)
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-03-19 09:19:33 UTC (rev 265)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-03-19 13:35:53 UTC (rev 266)
@@ -184,13 +184,13 @@
def handleDirtyOnClose(self):
"""
Handle dirty status on close
-
+
@return: Accept event?
@rtype: bool
"""
if not self.isDirty():
return True
-
+
mb = qtutils.saveMB(
self,
self.trUtf8("Unsaved changes!"),
@@ -411,33 +411,32 @@
def on_pingthread_started(self):
self.button_ping.setEnabled(False)
self.tw_ping.clearContents()
-
+
def on_pingthread_done(self):
self.button_ping.setEnabled(True)
def on_pingthread_server(self, i, name):
- row = self.tw_ping.rowCount()
+ tw = self.tw_ping
+ row = tw.rowCount()
if row < (i+1):
- self.tw_ping.setRowCount(i + 1)
+ tw.setRowCount(i + 1)
proto = QtGui.QTableWidgetItem()
font = QtGui.QFont()
- font.setPointSize(7)
+ font.setPointSize(9)
proto.setFont(font)
proto.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- header = QtGui.QTableWidgetItem(proto)
- header.setText(QtCore.QString.number(row + 1))
+ #tw.setVerticalHeaderItem(i, QtGui.QTableWidgetItem())
+ #tw.verticalHeaderItem(i).setSizeHint(QtCore.QSize(0, 0))
item0 = QtGui.QTableWidgetItem(proto)
item0.setText(name)
+ tw.setItem(i, 0, item0)
+ tw.setItem(i, 1, QtGui.QTableWidgetItem(proto))
+ tw.setItem(i, 2, QtGui.QTableWidgetItem(proto))
+ tw.resizeRowsToContents()
- self.tw_ping.setVerticalHeaderItem(i, header)
- self.tw_ping.setItem(i, 0, item0)
- self.tw_ping.setItem(i, 1, QtGui.QTableWidgetItem(proto))
- self.tw_ping.setItem(i, 2, QtGui.QTableWidgetItem(proto))
- self.tw_ping.resizeRowsToContents()
-
def on_pingthread_dns(self, i, time):
item = self.tw_ping.item(i, 1)
item.setText("%0.3f" % time)
@@ -479,13 +478,13 @@
self.servers = servers
if not self.isRunning():
self.start()
-
+
def run(self):
# TODO: thread safety!
# emit a list of names first
for i, server in enumerate(self.servers):
self.emit(SIGNAL("server(int, const QString&)"), i, server.name)
-
+
for i, server in enumerate(self.servers):
name = server.name
dns = server.dns()
@@ -495,7 +494,7 @@
i, errno, msg)
continue
self.emit(SIGNAL("dns(int, float)"), i, dns)
-
+
ping = server.portping()
if isSocketError(ping):
errno, msg = fmtSocketError(ping)
@@ -522,7 +521,7 @@
# TODO check this
self._running = False
self.condition.wakeAll()
-
+
def __del__(self):
self.stopChecker()
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-03-19 09:19:33 UTC (rev 265)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-03-19 13:35:53 UTC (rev 266)
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-# Form implementation generated from reading ui file 'src/moul/qt/ui/mainwindow.ui'
+# Form implementation generated from reading ui file './src/moul/qt/ui/mainwindow.ui'
#
-# Created: Mon Mar 19 10:09:02 2007
+# Created: Mon Mar 19 14:34:52 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -1010,8 +1010,13 @@
spacerItem10 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
self.gridlayout3.addItem(spacerItem10,0,5,1,1)
+ self.lb_localtime = QtGui.QLabel(self.groupBox_4)
+ self.lb_localtime.setGeometry(QtCore.QRect(360,250,81,20))
+ self.lb_localtime.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
+ self.lb_localtime.setObjectName("lb_localtime")
+
self.tw_eg = QtGui.QTableWidget(self.groupBox_4)
- self.tw_eg.setGeometry(QtCore.QRect(10,90,431,131))
+ self.tw_eg.setGeometry(QtCore.QRect(10,90,431,151))
font = QtGui.QFont(self.tw_eg.font())
font.setPointSize(8)
@@ -1020,11 +1025,6 @@
self.tw_eg.setDragDropOverwriteMode(False)
self.tw_eg.setAlternatingRowColors(True)
self.tw_eg.setObjectName("tw_eg")
-
- self.lb_localtime = QtGui.QLabel(self.groupBox_4)
- self.lb_localtime.setGeometry(QtCore.QRect(360,230,81,20))
- self.lb_localtime.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
- self.lb_localtime.setObjectName("lb_localtime")
self.tab_sub_time.addTab(self.tab_time_eder,"")
self.tab_time_podages = QtGui.QWidget()
@@ -1035,8 +1035,13 @@
self.groupBox_6.setGeometry(QtCore.QRect(10,0,451,371))
self.groupBox_6.setObjectName("groupBox_6")
+ self.lb_localtime_2 = QtGui.QLabel(self.groupBox_6)
+ self.lb_localtime_2.setGeometry(QtCore.QRect(360,190,81,20))
+ self.lb_localtime_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
+ self.lb_localtime_2.setObjectName("lb_localtime_2")
+
self.tw_pods = QtGui.QTableWidget(self.groupBox_6)
- self.tw_pods.setGeometry(QtCore.QRect(10,30,431,131))
+ self.tw_pods.setGeometry(QtCore.QRect(10,30,431,151))
font = QtGui.QFont(self.tw_pods.font())
font.setPointSize(8)
@@ -1045,11 +1050,6 @@
self.tw_pods.setDragDropOverwriteMode(False)
self.tw_pods.setAlternatingRowColors(True)
self.tw_pods.setObjectName("tw_pods")
-
- self.lb_localtime_2 = QtGui.QLabel(self.groupBox_6)
- self.lb_localtime_2.setGeometry(QtCore.QRect(360,170,81,20))
- self.lb_localtime_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
- self.lb_localtime_2.setObjectName("lb_localtime_2")
self.tab_sub_time.addTab(self.tab_time_podages,"")
self.tabwidget.addTab(self.tab_time,"")
@@ -1316,6 +1316,7 @@
self.label_13.setText(QtGui.QApplication.translate("MainWindow", "Light level", None, QtGui.QApplication.UnicodeUTF8))
self.label_14.setText(QtGui.QApplication.translate("MainWindow", "Length", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("MainWindow", "Time", None, QtGui.QApplication.UnicodeUTF8))
+ self.lb_localtime.setText(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
self.tw_eg.clear()
self.tw_eg.setColumnCount(3)
self.tw_eg.setRowCount(0)
@@ -1331,13 +1332,12 @@
headerItem5 = QtGui.QTableWidgetItem()
headerItem5.setText(QtGui.QApplication.translate("MainWindow", "Dusk", None, QtGui.QApplication.UnicodeUTF8))
self.tw_eg.setHorizontalHeaderItem(2,headerItem5)
- self.lb_localtime.setText(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
self.tab_sub_time.setTabText(self.tab_sub_time.indexOf(self.tab_time_eder), QtGui.QApplication.translate("MainWindow", "Eder Gira", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_6.setTitle(QtGui.QApplication.translate("MainWindow", "Gate appearence", None, QtGui.QApplication.UnicodeUTF8))
+ self.lb_localtime_2.setText(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
self.tw_pods.clear()
self.tw_pods.setColumnCount(0)
self.tw_pods.setRowCount(0)
- self.lb_localtime_2.setText(QtGui.QApplication.translate("MainWindow", "local time", None, QtGui.QApplication.UnicodeUTF8))
self.tab_sub_time.setTabText(self.tab_sub_time.indexOf(self.tab_time_podages), QtGui.QApplication.translate("MainWindow", "Pod Ages", None, QtGui.QApplication.UnicodeUTF8))
self.tabwidget.setTabText(self.tabwidget.indexOf(self.tab_time), QtGui.QApplication.translate("MainWindow", "Time", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_5.setTitle(QtGui.QApplication.translate("MainWindow", "Read chatlogs", None, QtGui.QApplication.UnicodeUTF8))
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-03-19 09:19:33 UTC (rev 265)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-03-19 13:35:53 UTC (rev 266)
@@ -2180,13 +2180,29 @@
</item>
</layout>
</widget>
+ <widget class="QLabel" name="lb_localtime" >
+ <property name="geometry" >
+ <rect>
+ <x>360</x>
+ <y>250</y>
+ <width>81</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>local time</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
<widget class="QTableWidget" name="tw_eg" >
<property name="geometry" >
<rect>
<x>10</x>
<y>90</y>
<width>431</width>
- <height>131</height>
+ <height>151</height>
</rect>
</property>
<property name="font" >
@@ -2219,22 +2235,6 @@
</property>
</column>
</widget>
- <widget class="QLabel" name="lb_localtime" >
- <property name="geometry" >
- <rect>
- <x>360</x>
- <y>230</y>
- <width>81</width>
- <height>20</height>
- </rect>
- </property>
- <property name="text" >
- <string>local time</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
</widget>
</widget>
<widget class="QWidget" name="tab_time_podages" >
@@ -2256,13 +2256,29 @@
<property name="title" >
<string>Gate appearence</string>
</property>
+ <widget class="QLabel" name="lb_localtime_2" >
+ <property name="geometry" >
+ <rect>
+ <x>360</x>
+ <y>190</y>
+ <width>81</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>local time</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
<widget class="QTableWidget" name="tw_pods" >
<property name="geometry" >
<rect>
<x>10</x>
<y>30</y>
<width>431</width>
- <height>131</height>
+ <height>151</height>
</rect>
</property>
<property name="font" >
@@ -2280,22 +2296,6 @@
<bool>true</bool>
</property>
</widget>
- <widget class="QLabel" name="lb_localtime_2" >
- <property name="geometry" >
- <rect>
- <x>360</x>
- <y>170</y>
- <width>81</width>
- <height>20</height>
- </rect>
- </property>
- <property name="text" >
- <string>local time</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
</widget>
</widget>
</widget>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-04-16 18:45:32
|
Revision: 283
http://pymoul.svn.sourceforge.net/pymoul/?rev=283&view=rev
Author: tiran
Date: 2007-04-16 11:45:31 -0700 (Mon, 16 Apr 2007)
Log Message:
-----------
Added pak and sdl reader. Fixed Uru String
Modified Paths:
--------------
pymoul/trunk/src/moul/crypt/binary.py
Added Paths:
-----------
pymoul/trunk/src/moul/file/pak.py
pymoul/trunk/src/moul/file/sdl.py
pymoul/trunk/src/moul/file/tests/test_sdl.py
Modified: pymoul/trunk/src/moul/crypt/binary.py
===================================================================
--- pymoul/trunk/src/moul/crypt/binary.py 2007-04-15 22:27:52 UTC (rev 282)
+++ pymoul/trunk/src/moul/crypt/binary.py 2007-04-16 18:45:31 UTC (rev 283)
@@ -102,17 +102,19 @@
if self.version in (0, 5):
size = size & 0x0FFF
if size > 1024: # XXX: ???
- raise ValueError("size '%i' > 1024 at position %s(%s)" %
+ raise ValueError("size '%i' > 1024 at position %s(%s)" %
(size, fd.tell(), repr(fd)))
if self.version == 5:
# XXX: testme
# read data as tuple of integeres
- data = fd.readPacked("<%iI" % size)
+ #data = fd.readPacked("<%iB" % size)
+ data = fd.read(size)
# OR integers with 0xff and write their char equivalent to string
- result = ''.join([chr(d ^ 0xff) for d in data])
+ result = ''.join([chr(ord(d) ^ 0xff) for d in data])
elif self.version == 6:
- data = fd.readPacked("<%iI" % size)
- result = ''.join([chr(d ^ self.MYST5KEY[i%8])
+ #data = fd.readPacked("<%iB" % size)
+ data = fd.read(size)
+ result = ''.join([chr(ord(d) ^ self.MYST5KEY[i%8])
for i, d in enumerate(data)])
else:
result = fd.read(size)
Added: pymoul/trunk/src/moul/file/pak.py
===================================================================
--- pymoul/trunk/src/moul/file/pak.py (rev 0)
+++ pymoul/trunk/src/moul/file/pak.py 2007-04-16 18:45:31 UTC (rev 283)
@@ -0,0 +1,72 @@
+# pyMoul - Python interface to Myst Online URU Live
+# Copyright (C) 2007 Christian Heimes <christian (at) cheimes (dot) de>
+
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+"""Python PAK reader (for TPOS)
+"""
+__author__ = "Christian Heimes"
+__version__ = "$Id: utils.py 187 2007-02-23 16:41:50Z tiran $"
+__revision__ = "$Revision: 187 $"
+
+import os
+
+from moul.crypt.binary import BinaryFile
+
+class PAKReader(object):
+ """Read Python pak
+ """
+ magic = '\x3b\xf2\x0d\x0a\x00\x00\x00\x00'
+
+ def __init__(self, fname):
+ self._fname = fname
+ self._fd = BinaryFile(fname, 'rb')
+ self._files = {}
+ self._parseHeader()
+
+ def _parseHeader(self):
+ """Parse PAK header
+ """
+ fd = self._fd
+ fd.seek(0)
+ count = fd.read32()
+ for i in range(count):
+ name = fd.readUruString() + 'c' # pyc
+ offset = fd.read32()
+ self._files[name] = offset
+
+ def names():
+ return self._files.keys()
+
+ def getPycFile(self, name):
+ fd = self._fd
+ offset = self._files[name]
+ fd.seek(offset)
+ size = fd.read32()
+ data = fd.read(size)
+ return self.magic + data
+
+ def dump(self, path, create=False):
+ if create:
+ os.mkdir(path)
+ for name in self._files:
+ fd = open(os.path.join(path, name), 'wb')
+ fd.write(self.getPycFile(name))
+ fd.close()
+
+if __name__ == '__main__':
+ pak = PAKReader('python.pak')
+ pak.dump('pyc', True)
+
Property changes on: pymoul/trunk/src/moul/file/pak.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
Added: pymoul/trunk/src/moul/file/sdl.py
===================================================================
--- pymoul/trunk/src/moul/file/sdl.py (rev 0)
+++ pymoul/trunk/src/moul/file/sdl.py 2007-04-16 18:45:31 UTC (rev 283)
@@ -0,0 +1,117 @@
+# pyMoul - Python interface to Myst Online URU Live
+# Copyright (C) 2007 Christian Heimes <christian (at) cheimes (dot) de>
+
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+"""SDL files (for TPOS)
+"""
+__author__ = "Christian Heimes"
+__version__ = "$Id: utils.py 187 2007-02-23 16:41:50Z tiran $"
+__revision__ = "$Revision: 187 $"
+
+import os
+import re
+
+
+class SDLReader(object):
+ """Read Python pak
+
+ >>> mo = SDLReader.comment.match('abc # def # efg')
+ >>> mo.group('content')
+ 'abc '
+
+ >>> mo = SDLReader.comment.match('abc')
+ >>> mo.group('content')
+ 'abc'
+
+ >>> mo = SDLReader.comment.match('# abc')
+ >>> mo.group('content')
+ ''
+
+ >>> mo = SDLReader.statedesc.match('STATEDESC testage')
+ >>> mo.group('name')
+ 'testage'
+
+ >>> mo = SDLReader.version.match(' VERSION 5')
+ >>> mo.group('version')
+ '5'
+
+ >>> mo = SDLReader.var.search('VAR BOOL testvar[1] DEFAULT=1')
+ >>> mo.group('type')
+ 'BOOL'
+ >>> mo.group('name')
+ 'testvar'
+ >>> mo.group('tail')
+ ' DEFAULT=1'
+ """
+ comment = re.compile("^(?P<content>[^#]*)") # non greedy match
+ statedesc = re.compile("^STATEDESC[ ]+(?P<name>\w+)")
+ version = re.compile("[ \t]*VERSION[ ]+(?P<version>\d+)")
+ var = re.compile("VAR[ ]+(?P<type>\w+)[ ]+(?P<name>[$\w]+)\[1\](?P<tail>.*)")
+ def __init__(self, fname):
+ self._fname = fname
+ self._fd = open(fname, 'r')
+ self.states = []
+ self._parseFile()
+
+ def _parseFile(self):
+ for line in self._fd:
+ #line = self.comment.match(line).group('content')
+ mo = self.statedesc.match(line)
+ if mo:
+ self.states.append(mo.group('name')
+
+class SDLStates(object):
+ """SDL state object
+ """
+ def __init__(self, name):
+ self._name = name.strip()
+ self._version = None
+ self._vars = []
+
+ def _getVersion(self):
+ return self._version
+ def _setVersion(self, version):
+ self._version = int(version)
+ version = property(_getVersion, _setVersion)
+
+ @property
+ def id(self):
+ return "%s:%i" % (self.name, self.version)
+
+ @property
+ def name(self):
+ return self._name
+
+ def addVarTail(self, name, typ, tail):
+ elements = [el.strip() for el in tail.split('=')]
+ kwargs = {}
+ for name in ('DEFAULT', 'DEFAULTOPTION', 'DISPLAYOPTION'):
+ idx = elements.index(name)
+ if idx > -1:
+ kwargs[name.lower()] = elements[idx+1]
+ sdl = SDLVar(name, typ, **kwargs)
+ self._vars.append(sdl)
+
+class SDLVar(object):
+ """SDL variable
+ """
+ def __init__(self, name, typ, default=None, defaultoption=None,
+ displayoption=None):
+ self._name = name
+ self._typ = typ
+ self._default = default
+ self._defaultoption = defaultoption
+ self._displayoption = displayoption
Property changes on: pymoul/trunk/src/moul/file/sdl.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
Added: pymoul/trunk/src/moul/file/tests/test_sdl.py
===================================================================
--- pymoul/trunk/src/moul/file/tests/test_sdl.py (rev 0)
+++ pymoul/trunk/src/moul/file/tests/test_sdl.py 2007-04-16 18:45:31 UTC (rev 283)
@@ -0,0 +1,34 @@
+# pyMoul - Python interface to Myst Online URU Live
+# Copyright (C) 2007 Christian Heimes <christian (at) cheimes (dot) de>
+
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+"""moul.file.sdl unit tests
+"""
+__author__ = "Christian Heimes"
+__version__ = "$Id: test_plasmalog.py 140 2007-02-05 14:51:30Z tiran $"
+__revision__ = "$Revision: 140 $"
+
+import os
+import unittest
+from doctest import DocTestSuite
+
+def test_suite():
+ return unittest.TestSuite((
+ DocTestSuite('moul.file.sdl')
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest="test_suite")
Property changes on: pymoul/trunk/src/moul/file/tests/test_sdl.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-04-28 13:25:48
|
Revision: 287
http://pymoul.svn.sourceforge.net/pymoul/?rev=287&view=rev
Author: tiran
Date: 2007-04-28 06:25:46 -0700 (Sat, 28 Apr 2007)
Log Message:
-----------
Propset and minor tweaks for crypt
Modified Paths:
--------------
pymoul/trunk/src/moul/crypt/stream.py
pymoul/trunk/src/moul/file/pak.py
pymoul/trunk/src/moul/file/sdl.py
pymoul/trunk/src/moul/file/tests/test_sdl.py
Property Changed:
----------------
pymoul/trunk/src/moul/crypt/stream.py
pymoul/trunk/src/moul/file/pak.py
pymoul/trunk/src/moul/file/sdl.py
pymoul/trunk/src/moul/file/tests/test_sdl.py
Modified: pymoul/trunk/src/moul/crypt/stream.py
===================================================================
--- pymoul/trunk/src/moul/crypt/stream.py 2007-04-19 00:33:11 UTC (rev 286)
+++ pymoul/trunk/src/moul/crypt/stream.py 2007-04-28 13:25:46 UTC (rev 287)
@@ -18,8 +18,8 @@
"""Encrypted file stream
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: elf.py 275 2007-03-21 12:39:25Z tiran $"
-__revision__ = "$Revision: 275 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import os
@@ -35,27 +35,43 @@
blockSize = 1024
def __init__(self, fdname, cipher):
+ self._cipher = cipher
+
if isinstance(fdname, basestring):
fd = BinaryFile(fdname)
elif isinstance(fdname, BinaryFile):
fd = fdname
else:
raise TypeError(fdname)
+ self._fd = fd
+
header = fd.read(12)
if header != self.magic:
HeaderError(header)
self._size = fd.read32()
- fd.seek(0, 2)
- fsize = fd.tell()
- fd.seek(16)
- if fsize-16 < self._size:
+
+ self.seek(0, 2)
+ fsize = self.tell()
+ self.seek(0)
+ if fsize < self._size:
raise ValueError("Size mismatch %i/%i" % (fsize, self._size))
- self._cipher = cipher
- self._fd = fd
+ def seek(self, offset, whence=0):
+ if whence == 0:
+ offset += 16
+ self._fd.seek(offset, whence)
+
+ def tell(self):
+ return self._fd.tell()-16
+
+ def flush(self):
+ return self._fd.flush()
+
+ def close(self):
+ return self._fd.close()
+
def read(self):
fd = self._fd
- fd.seek(16)
remain = self._size
bs = self.blockSize
decrypt = self._cipher.decrypt
@@ -69,4 +85,5 @@
data = data[:remain]
buf.append(data)
remain -= bs
+ remain -= bs
return ''.join(buf)
Property changes on: pymoul/trunk/src/moul/crypt/stream.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
Modified: pymoul/trunk/src/moul/file/pak.py
===================================================================
--- pymoul/trunk/src/moul/file/pak.py 2007-04-19 00:33:11 UTC (rev 286)
+++ pymoul/trunk/src/moul/file/pak.py 2007-04-28 13:25:46 UTC (rev 287)
@@ -18,8 +18,8 @@
"""Python PAK reader (for TPOS)
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: utils.py 187 2007-02-23 16:41:50Z tiran $"
-__revision__ = "$Revision: 187 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import os
from hashlib import md5
Property changes on: pymoul/trunk/src/moul/file/pak.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
Modified: pymoul/trunk/src/moul/file/sdl.py
===================================================================
--- pymoul/trunk/src/moul/file/sdl.py 2007-04-19 00:33:11 UTC (rev 286)
+++ pymoul/trunk/src/moul/file/sdl.py 2007-04-28 13:25:46 UTC (rev 287)
@@ -18,8 +18,8 @@
"""SDL files (for TPOS)
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: utils.py 187 2007-02-23 16:41:50Z tiran $"
-__revision__ = "$Revision: 187 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import os
import re
Property changes on: pymoul/trunk/src/moul/file/sdl.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
Modified: pymoul/trunk/src/moul/file/tests/test_sdl.py
===================================================================
--- pymoul/trunk/src/moul/file/tests/test_sdl.py 2007-04-19 00:33:11 UTC (rev 286)
+++ pymoul/trunk/src/moul/file/tests/test_sdl.py 2007-04-28 13:25:46 UTC (rev 287)
@@ -18,8 +18,8 @@
"""moul.file.sdl unit tests
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: test_plasmalog.py 140 2007-02-05 14:51:30Z tiran $"
-__revision__ = "$Revision: 140 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import os
import unittest
Property changes on: pymoul/trunk/src/moul/file/tests/test_sdl.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-05-24 17:19:05
|
Revision: 291
http://pymoul.svn.sourceforge.net/pymoul/?rev=291&view=rev
Author: tiran
Date: 2007-05-24 10:19:06 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Chatlog parser enhancements
Modified Paths:
--------------
pymoul/trunk/src/moul/chatrelay/io.py
pymoul/trunk/src/moul/chatrelay/ircclient.py
pymoul/trunk/src/moul/file/chatlog.py
pymoul/trunk/src/moul/file/tests/test_chatlog.py
Modified: pymoul/trunk/src/moul/chatrelay/io.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 14:00:41 UTC (rev 290)
+++ pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 17:19:06 UTC (rev 291)
@@ -23,6 +23,10 @@
import os
+from moul.file.chatlog import ChatlogParser
+from moul.file.chatlog import ChatLineError
+from moul.file.chatlog import CHAT_PRIVMSG
+
class NullFormatter(object):
"""A formatter that doesn't change the msg
"""
@@ -62,10 +66,16 @@
return
lines = data.split(os.linesep)
# XXX - KISS, don't check for imcomplete lines
- for line in lines:
- line = line.strip()
- if line:
- self._fifo.append(line)
+ for line in ChatlogParser(lines):
+ if isinstance(ChatLineError):
+ self._fifo.append("PARSER ERROR: " + line)
+ else:
+ if line.typ & CHAT_PRIVMSG:
+ continue
+ elif line.important:
+ self._fifo.append("*** " + line)
+ else:
+ self._fifo.append(line)
def __iter__(self):
self._read()
@@ -80,8 +90,6 @@
class MessageWriter(object):
"""Write messages to a channel
"""
- maxlength = 80
-
def __init__(self, client, channel, formatter=None):
self._client = client
self._channel = channel
@@ -91,4 +99,4 @@
def log(self, msg):
msg = self._fmt.format(msg)
- self._client.say(self._channel, msg, self.maxlength)
+ self._client.say(self._channel, msg)
Modified: pymoul/trunk/src/moul/chatrelay/ircclient.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 14:00:41 UTC (rev 290)
+++ pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 17:19:06 UTC (rev 291)
@@ -238,7 +238,7 @@
reactor.callLater(3.0, self.reply, reply, "0-/")
reactor.callLater(3.5, self.reply, reply, "0-\\")
- #@requirePasswd
+ @requirePasswd
@usage("Open the chatlog and start relaying")
def command_STARTLOG(self, user, reply, args):
self.reply(reply, 'Opening chatlog ...')
@@ -248,12 +248,12 @@
return
self.msg(self.channel, "*** I'm relaying chat ***")
- #@requirePasswd
+ @requirePasswd
@usage("Stop relaying")
def command_STOPLOG(self, user, reply, args):
self.stop()
self.reply(reply, 'chatlog closed')
- self.msg(self.channel, "*** I've stopped to relay chat ***")
+ self.msg(self.channel, "*** I've stopped relaying chat ***")
class ThrottledClientFactory(protocol.ClientFactory):
lostDelay = 2
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 14:00:41 UTC (rev 290)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 17:19:06 UTC (rev 291)
@@ -41,7 +41,22 @@
from moul.file.utils import fileModTime
+# Chat line types
+CHAT_START = 1 << 0
+CHAT_STOP = 1 << 1
+CHAT_ERROR = 1 << 2
+CHAT_PRIVMSGFROM = 1 << 3
+CHAT_PRIVMSGTO = 1 << 4
+CHAT_PRIVMSG = CHAT_PRIVMSGFROM | CHAT_PRIVMSGTO
+CHAT_MSG = 1 << 5
+CHAT_ACTION = 1 << 6
+# users
+USER_CYAN = ['gregbert', 'greydragon']
+USER_DRC = ['Marie Sutherland', 'Douglas Sharper', 'Nick White',
+ 'Dr. Kodama', 'Victor Laxman', 'Michael Engberg']
+USER_IMPORTANT = USER_CYAN + USER_DRC
+
RE_FLAGS = re.LOCALE
CHAT_RE = re.compile(
r"^\((?P<M>\d{1,2})/(?P<D>\d{1,2})\ " # MM/DD
@@ -52,20 +67,20 @@
r"^\((?P<date>[\d/]*)\ (?P<time>[\d:]*)\)" # (date time)
r"(?P<space>\s{1,2})" # spaces
r"(?P<msg>.*)$", # message
- RE_FLAGS)
-CHATLOG_STARTED = "Chat.log started..."
-CHATLOG_STOPPED = "...Chat.log stopped."
-TEXT_MSGFROM_RE = re.compile(
+ RE_FLAGS)
+CHATLOG_START = "Chat.log started..."
+CHATLOG_STOP = "...Chat.log stopped."
+PRIVMSGFROM_RE = re.compile(
# From USER in LOCATION: msg
r"From (?P<user>.*) in (?P<location>.*): (?P<msg>.*)",
RE_FLAGS)
-TEXT_MSGTO_RE = re.compile(
+PRIVMSGTO_RE = re.compile(
r"To (?P<user>.*): (?P<msg>.*)", # From USER in LOCATION: msg
RE_FLAGS)
-TEXT_ERROR_RE = re.compile(
+ERROR_RE = re.compile(
r"Error: (?P<msg>.*)", # Error: message
RE_FLAGS)
-TEXT_RE = re.compile(
+MSG_RE = re.compile(
r"(?P<user>.*): (?P<msg>.*)", # User: message
RE_FLAGS)
CHATLOG_DATE_FNAME_RE = re.compile(
@@ -76,7 +91,6 @@
LOG = getLogger('moul.chat')
-
class ChatlogMover(object):
"""
"""
@@ -147,7 +161,7 @@
created = None
if mo:
data = mo.groupdict()
- if data['msg'].startswith(CHATLOG_STARTED):
+ if data['msg'].startswith(CHATLOG_START):
d = mo.groupdict()
created = (None, int(d['M']), int(d['D']), int(d['h']),
int(d['m']), int(d['s']), None, None, None)
@@ -255,6 +269,8 @@
class ChatlogView(object):
"""A view of a single chat log file
+
+ XXX replace it with ChatlogParser
"""
def __init__(self, fname):
@@ -326,3 +342,85 @@
"""
self.open()
return self._fd.read()
+
+class ChatlogParser(object):
+ """Yet another chatlog parser
+
+ New idea, new design
+ """
+ def __init__(self, iterable, year=2007):
+ self._iterable = iterable
+ self._year = year # XXX
+
+ def parse(self, line):
+ mo = CHAT_RE.match(line)
+ if mo is None:
+ self.error(line)
+ return
+ d = mo.groupdict()
+ date = (self._year, int(d['M']), int(d['D']),
+ int(d['h']), int(d['m']), int(d['s']))
+ typ = None
+ msg = d['msg']
+ info = {}
+ important = False
+ if len(d['space']) == 2:
+ typ = CHAT_MSG
+ mo = MSG_RE.match(msg)
+ if mo is None:
+ return ChatLineError(line)
+ info = mo.groupdict()
+ else:
+ if msg == CHATLOG_START:
+ typ = CHAT_START
+ elif msg == CHATLOG_STOP:
+ typ = CHAT_STOP
+ else:
+ for t, r in ((CHAT_PRIVMSGFROM, PRIVMSGFROM_RE),
+ (CHAT_PRIVMSGTO, PRIVMSGTO_RE),
+ (CHAT_ERROR, ERROR_RE)):
+ mo = r.match(msg)
+ if mo:
+ typ = t
+ info = mo.groupdict()
+ break
+ if typ is None:
+ typ = CHAT_ACTION
+ for user in USER_IMPORTANT:
+ if user in msg:
+ important = True
+
+ user = info.get('user', None)
+ if user:
+ if user in USER_IMPORTANT:
+ important = True
+ if typ is not None:
+ return ChatLine(msg, date, typ, important, info)
+ else:
+ return ChatLineError(line)
+
+ def __iter__(self):
+ for line in self._iterable:
+ yield self.parse(line)
+
+class ChatLine(unicode):
+ __slots__ = ('datetime', 'typ', 'important', 'info')
+
+ def __new__(cls, ustr, datetime, typ=None, important=False, info={}):
+ self = unicode.__new__(cls, ustr)
+ self.datetime = datetime
+ self.typ = typ
+ self.important = important
+ self.info = info
+ return self
+
+ def asDatetime(self):
+ return datetime(*self.date)
+
+class ChatLineError(unicode):
+ def __new__(cls, ustr):
+ self = unicode.__new__(cls, ustr)
+ return self
+
+ def __nonzero(self):
+ return False
\ No newline at end of file
Modified: pymoul/trunk/src/moul/file/tests/test_chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/tests/test_chatlog.py 2007-05-24 14:00:41 UTC (rev 290)
+++ pymoul/trunk/src/moul/file/tests/test_chatlog.py 2007-05-24 17:19:06 UTC (rev 291)
@@ -25,10 +25,37 @@
from doctest import DocTestSuite
import moul.file.chatlog
+from moul.file.chatlog import *
+TEST_LOG = """(01/02 03:04:05) Chat.log started...
+(01/02 03:04:05) ...Chat.log stopped.
+(01/02 03:04:05) From USER in LOCATION: MSG
+(01/02 03:04:05) Error: ERRORMSG
+(01/02 03:04:05) USER: TEXT (note the two spaces!)
+(01/02 03:04:05) To USER: TEXT
+(01/02 03:04:05) USER action""".split('\n')
+class ChatlogParserTest(unittest.TestCase):
+
+ def test_parse(self):
+ parser = ChatlogParser(TEST_LOG)
+ results = list(iter(parser))
+ fue = self.failUnlessEqual
+ for result in results:
+ fue(result.datetime, (2007, 1, 2, 3, 4, 5))
+ fue(results[0].typ, CHAT_START)
+ fue(results[1].typ, CHAT_STOP)
+ fue(results[2].typ, CHAT_PRIVMSGFROM)
+ fue(results[3].typ, CHAT_ERROR)
+ fue(results[4].typ, CHAT_MSG)
+ fue(results[5].typ, CHAT_PRIVMSGTO)
+ fue(results[6].typ, CHAT_ACTION)
+ for i in (2, 4, 5):
+ fue(results[i].info['user'], 'USER')
+
def test_suite():
return unittest.TestSuite((
+ unittest.makeSuite(ChatlogParserTest),
DocTestSuite('moul.file.chatlog')
))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-05-24 17:53:50
|
Revision: 293
http://pymoul.svn.sourceforge.net/pymoul/?rev=293&view=rev
Author: tiran
Date: 2007-05-24 10:53:52 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Fixed misc bugs in the formatter and writer
Modified Paths:
--------------
pymoul/trunk/src/moul/chatrelay/io.py
pymoul/trunk/src/moul/chatrelay/ircclient.py
pymoul/trunk/src/moul/file/chatlog.py
Modified: pymoul/trunk/src/moul/chatrelay/io.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 17:41:19 UTC (rev 292)
+++ pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 17:53:52 UTC (rev 293)
@@ -40,16 +40,22 @@
self.skipprivate = skipprivate
def format(self, msg):
- if self.skipprivate and msg.typ & CHAT_PRIVMSG:
- result = None
- elif msg.typ == CHAT_PRIVMSGTO:
- result = "-> %s" % msg
- elif msg.typ == CHAT_PRIVMSGFROM:
- result = "<- %s" % msg
- elif msg.typ == CHAT_ACTION:
- result = "* %s" % msg
- if msg.important:
- result = "%B%s" msg
+ print msg.typ, msg
+ if not msg:
+ return None
+ typ = getattr(msg, 'typ', CHAT_UNKNOWN)
+ important = getattr(msg, 'important', False)
+
+ if self.skipprivate and typ & CHAT_PRIVMSG:
+ return None
+ elif typ == CHAT_PRIVMSGTO:
+ msg = "-> %s" % msg
+ elif typ == CHAT_PRIVMSGFROM:
+ msg = "<- %s" % msg
+ elif typ == CHAT_ACTION:
+ msg = "* %s" % msg
+ if important:
+ msg = "%B%s" % msg
return str(msg)
class LogFileReader(object):
Modified: pymoul/trunk/src/moul/chatrelay/ircclient.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 17:41:19 UTC (rev 292)
+++ pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 17:53:52 UTC (rev 293)
@@ -33,6 +33,7 @@
from moul.chatrelay.io import MessageWriter
from moul.chatrelay.io import LogFileReader
+from moul.chatrelay.io import MOULLogFormatter
from moul.osdependent import getMoulUserDataDir
datadir = getMoulUserDataDir()
@@ -299,7 +300,7 @@
self.adminpasswd)
p.factory = self
p.reader = self.readerClass(chatlog)
- p.writer = self.writerClass(p, self.channel)
+ p.writer = self.writerClass(p, self.channel, formatter=MOULLogFormatter(False))
self.p = p
return p
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 17:41:19 UTC (rev 292)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 17:53:52 UTC (rev 293)
@@ -384,7 +384,7 @@
typ = t
info = mo.groupdict()
break
- if typ is None:
+ if typ == CHAT_UNKNOWN: # XXX check this
typ = CHAT_ACTION
for user in USER_IMPORTANT:
if user in msg:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-05-24 22:50:20
|
Revision: 294
http://pymoul.svn.sourceforge.net/pymoul/?rev=294&view=rev
Author: tiran
Date: 2007-05-24 15:50:20 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Added more official DRC and Cyan members
Added filter for non important people
Modified Paths:
--------------
pymoul/trunk/src/moul/chatrelay/__init__.py
pymoul/trunk/src/moul/chatrelay/io.py
pymoul/trunk/src/moul/chatrelay/ircclient.py
pymoul/trunk/src/moul/file/chatlog.py
Property Changed:
----------------
pymoul/trunk/src/moul/chatrelay/__init__.py
pymoul/trunk/src/moul/chatrelay/io.py
pymoul/trunk/src/moul/chatrelay/ircclient.py
Modified: pymoul/trunk/src/moul/chatrelay/__init__.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/__init__.py 2007-05-24 17:53:52 UTC (rev 293)
+++ pymoul/trunk/src/moul/chatrelay/__init__.py 2007-05-24 22:50:20 UTC (rev 294)
@@ -18,5 +18,5 @@
"""
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: __init__.py 108 2007-01-31 14:46:54Z tiran $"
-__revision__ = "$Revision: 108 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
Property changes on: pymoul/trunk/src/moul/chatrelay/__init__.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
Modified: pymoul/trunk/src/moul/chatrelay/io.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 17:53:52 UTC (rev 293)
+++ pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 22:50:20 UTC (rev 294)
@@ -18,12 +18,11 @@
"""
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: __init__.py 108 2007-01-31 14:46:54Z tiran $"
-__revision__ = "$Revision: 108 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import os
-from moul.file.chatlog import ChatlogParser
from moul.file.chatlog import *
class NullFormatter(object):
@@ -36,16 +35,18 @@
"""Formatter for MOUL
"""
- def __init__(self, skipprivate=True):
+ def __init__(self, skipprivate=False, onlyimportant=False):
self.skipprivate = skipprivate
+ self.onlyimportant = onlyimportant
def format(self, msg):
- print msg.typ, msg
if not msg:
return None
typ = getattr(msg, 'typ', CHAT_UNKNOWN)
important = getattr(msg, 'important', False)
-
+
+ if self.onlyimportant and not important:
+ return None
if self.skipprivate and typ & CHAT_PRIVMSG:
return None
elif typ == CHAT_PRIVMSGTO:
@@ -54,7 +55,7 @@
msg = "<- %s" % msg
elif typ == CHAT_ACTION:
msg = "* %s" % msg
- if important:
+ if not self.onlyimportant and important:
msg = "%B%s" % msg
return str(msg)
Property changes on: pymoul/trunk/src/moul/chatrelay/io.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
Modified: pymoul/trunk/src/moul/chatrelay/ircclient.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 17:53:52 UTC (rev 293)
+++ pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 22:50:20 UTC (rev 294)
@@ -20,8 +20,8 @@
Partly based on Buildbot's IRC support
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: __init__.py 108 2007-01-31 14:46:54Z tiran $"
-__revision__ = "$Revision: 108 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import sys
import os
@@ -271,6 +271,7 @@
p = None
readerClass = LogFileReader
writerClass = MessageWriter
+ formatter = MOULLogFormatter(skipprivate=False, onlyimportant=False)
def __init__(self, nickname, channel, realname=None, username=None,
serverpasswd=None, nickpasswd=None, adminpasswd=None):
@@ -300,7 +301,7 @@
self.adminpasswd)
p.factory = self
p.reader = self.readerClass(chatlog)
- p.writer = self.writerClass(p, self.channel, formatter=MOULLogFormatter(False))
+ p.writer = self.writerClass(p, self.channel, formatter=self.formatter)
self.p = p
return p
Property changes on: pymoul/trunk/src/moul/chatrelay/ircclient.py
___________________________________________________________________
Name: svn:keywords
- 'Id Revision'
+ Id Revision
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 17:53:52 UTC (rev 293)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 22:50:20 UTC (rev 294)
@@ -53,9 +53,17 @@
CHAT_ACTION = 1 << 6
# users
-USER_CYAN = ['gregbert', 'greydragon']
-USER_DRC = ['Marie Sutherland', 'Douglas Sharper', 'Nick White',
- 'Dr. Kodama', 'Victor Laxman', 'Michael Engberg']
+USER_CYAN = [
+ 'gregbert', 'greydragon', 'Rand Miller', 'ResEng B. Mathias',
+ 'ResEng B.Dreschel', 'ResEng C. Lambert', 'ResEng KJohnson',
+ 'ResEng 102', 'ResEng 233',
+ ]
+USER_DRC = [
+ 'Cate Alexander', 'Dr. Kodama', 'Marie Sutherland', 'Michael Engberg',
+ 'Victor Laxman', 'Wheely', 'Douglas Sharper', 'Phil Henderson',
+ 'Nick White'
+ ]
+
USER_IMPORTANT = USER_CYAN + USER_DRC
RE_FLAGS = re.LOCALE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-05-28 16:53:04
|
Revision: 295
http://pymoul.svn.sourceforge.net/pymoul/?rev=295&view=rev
Author: tiran
Date: 2007-05-28 09:53:00 -0700 (Mon, 28 May 2007)
Log Message:
-----------
Switching to a new implementation of the IRC chat relay system
Modified Paths:
--------------
pymoul/trunk/src/moul/chatrelay/__init__.py
pymoul/trunk/src/moul/chatrelay/io.py
pymoul/trunk/src/moul/chatrelay/ircclient.py
pymoul/trunk/src/moul/file/chatlog.py
Added Paths:
-----------
pymoul/trunk/src/moul/chatrelay/filter.py
pymoul/trunk/src/moul/chatrelay/formatter.py
pymoul/trunk/src/moul/chatrelay/interfaces.py
pymoul/trunk/src/moul/chatrelay/parser.py
Modified: pymoul/trunk/src/moul/chatrelay/__init__.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/__init__.py 2007-05-24 22:50:20 UTC (rev 294)
+++ pymoul/trunk/src/moul/chatrelay/__init__.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -5,7 +5,7 @@
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
Added: pymoul/trunk/src/moul/chatrelay/filter.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/filter.py (rev 0)
+++ pymoul/trunk/src/moul/chatrelay/filter.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -0,0 +1,56 @@
+from zope.interface import implements
+
+from moul.chatrelay.interfaces import ILineFilter
+from moul.chatrelay.interfaces import ISnoopyLineFilter
+from moul.file.chatlog import (CHAT_UNKNOWN, CHAT_PRIVMSG, CHAT_PRIVMSGTO,
+ CHAT_PRIVMSGFROM, CHAT_ACTION, CHAT_ERROR,
+ CHAT_MSG)
+
+__all__ = [obj for obj in globals() if ILineFilter.isImplementedBy(obj)]
+
+class NullFilter(object):
+ implements(ILineFilter)
+ name = 'Null filter'
+
+ def filter(self, line, **kwargs):
+ return line, kwargs
+
+class HightlightImportantFilter(object):
+ implements(ILineFilter)
+ name = 'Highlight important people'
+
+ def filter(self, line, **kwargs):
+ if kwargs.get('important', False):
+ kwargs['highlight'] = True
+ return line, kwargs
+
+class AbstractMessageFilter(object):
+ implements(ILineFilter)
+ name = None
+ msg_type = None
+
+ def __init__(self):
+ assert self.msg_type, "No message type applied"
+
+ def filter(self, line, **kwargs):
+ typ = kwargs.get('type', CHAT_UNKNOWN)
+ if typ & self.msg_type:
+ return None, None
+ return line, kwargs
+
+class PrivateMessageFilter(AbstractMessageFilter):
+ name = 'Private message filter'
+ msg_type = CHAT_PRIVMSG
+
+class ErrorMessageFilter(AbstractMessageFilter):
+ name = 'Error message filter'
+ msg_type = CHAT_ERROR
+
+class NonImportantFilter(object):
+ implements(ILineFilter)
+ name = 'Filter non important'
+
+ def filter(self, line, **kwargs):
+ if not kwargs.get('important', False):
+ return None, None
+ return line, kwargs
Property changes on: pymoul/trunk/src/moul/chatrelay/filter.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
Added: pymoul/trunk/src/moul/chatrelay/formatter.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/formatter.py (rev 0)
+++ pymoul/trunk/src/moul/chatrelay/formatter.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -0,0 +1,32 @@
+from zope.interface import implements
+
+from moul.chatrelay.interfaces import IOutputFormatter
+from moul.file.chatlog import (CHAT_UNKNOWN, CHAT_PRIVMSG, CHAT_PRIVMSGTO,
+ CHAT_PRIVMSGFROM, CHAT_ACTION, CHAT_ERROR,
+ CHAT_MSG)
+
+__all__ = [obj for obj in globals() if IOutputFormatter.isImplementedBy(obj)]
+
+class NullFormatter(object):
+ implements(IOutputFormatter)
+ name = 'Null formatter'
+
+ def format(self, line, **kwargs):
+ return line
+
+class MOULFormatter(object):
+ implements(IOutputFormatter)
+ name = 'MOUL formatter'
+
+ def format(self, line, **kwargs):
+ typ = kwargs.get('type', CHAT_UNKNOWN)
+ highlight = kwargs.get('highlight', False)
+ if typ == CHAT_PRIVMSGTO:
+ line = "-> %s" % line
+ elif typ == CHAT_PRIVMSGFROM:
+ line = "<- %s" % line
+ elif typ == CHAT_ACTION:
+ line = "* %s" % line
+ if highlight:
+ line = "%B%s" % line
+ return line
Property changes on: pymoul/trunk/src/moul/chatrelay/formatter.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
Added: pymoul/trunk/src/moul/chatrelay/interfaces.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/interfaces.py (rev 0)
+++ pymoul/trunk/src/moul/chatrelay/interfaces.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -0,0 +1,123 @@
+from zope.interface import Attribute
+from zope.interface import Interface
+
+class IFileAppendWatchService(Interface):
+ """A service which monitors text files and calls the callback for new lines
+ """
+
+ def monitorFile(path, callback, errback=None):
+ """Monitor a file
+
+ @param path: path to a file
+ @type path: string
+ @param callback: callback function(path, line)
+ @type callback: callable
+ @param errback: errback function(path, error)
+ @type errback: callable
+ """
+
+ def unmonitorFile(path):
+ """Stop monitoring files
+
+ @param path: path to a file
+ @type path: string
+ """
+
+ def listFiles():
+ """List monitored files
+
+ @return: a list of file names
+ @rtype: list
+ """
+
+class IInputParser(Interface):
+ """Parse input data
+ """
+ name = Attribute("name of the parser")
+
+ def parse(line):
+ """Parse a single line
+
+ @param line: input line
+ @type line: string
+ @return: parsed line, dict with additional information
+ @rtype: (string, dict)
+ """
+
+class ILineFilter(Interface):
+ """A line filter
+ """
+ name = Attribute("name of the filter")
+
+ def filter(line, **kwargs):
+ """
+
+ @param line: the line to filter
+ @type line: string
+ @param kwargs: additional information
+ @return: (filtered line, kwargs) or None, None
+ @rtype: (string, dict) / None, None
+ """
+
+class ISnoopyLineFilter(ILineFilter):
+ """A line filter that snoops the ongoing chat in the channel
+ """
+
+ def snoop(channel, user, msg):
+ """
+
+ @param channel: channel name
+ @type channel: string
+ @param user: user name with hostmask
+ @type user: string
+ @param msg: message
+ @type msg: string
+ @return: None
+ """
+
+class IOutputFormatter(Interface):
+ """A line formatter
+ """
+ name = Attribute("name of the output formatter")
+
+ def format(line, **kwargs):
+ """Format a line
+
+ @param line: the line to filter
+ @type line: string
+ @param kwargs: additional information
+ @return: a formatted line
+ @rtype: string
+ """
+
+class IChatRelay(Interface):
+ """A chat relay
+ """
+
+ def registerInputParser(parser):
+ """Register the input parser, overriding the old one
+
+ @param parser: an input parser object
+ @type parser: object providing IInputParser
+ """
+
+ def registerOutputFormatter(formatter):
+ """Register the output formatter, overriding the old one
+
+ @param formatter: an output formatter object
+ @type formatter: object providing IOutputFormatter
+ """
+
+ def registerFilters(*filters):
+ """
+
+ @param formatter: an output formatter object
+ @type formatter: object providing IOutputFormatter
+ """
+
+ def removeFilter(name):
+ """Remove a filter from the list of filters
+
+ @param name: name of the filter
+ @type name: string
+ """
Property changes on: pymoul/trunk/src/moul/chatrelay/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
Modified: pymoul/trunk/src/moul/chatrelay/io.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/io.py 2007-05-24 22:50:20 UTC (rev 294)
+++ pymoul/trunk/src/moul/chatrelay/io.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -5,7 +5,7 @@
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@@ -34,7 +34,7 @@
class MOULLogFormatter(NullFormatter):
"""Formatter for MOUL
"""
-
+
def __init__(self, skipprivate=False, onlyimportant=False):
self.skipprivate = skipprivate
self.onlyimportant = onlyimportant
@@ -44,7 +44,7 @@
return None
typ = getattr(msg, 'typ', CHAT_UNKNOWN)
important = getattr(msg, 'important', False)
-
+
if self.onlyimportant and not important:
return None
if self.skipprivate and typ & CHAT_PRIVMSG:
@@ -74,7 +74,7 @@
def open(self):
self._fd = open(self._fname, 'r')
self._fd.seek(0, 2) # eof
-
+
def close(self):
if self._fd:
self._fd.close()
@@ -85,7 +85,7 @@
@property
def isOpen(self):
return self._fd is not None
-
+
def _read(self):
data = self._fd.read()
if not data:
@@ -104,7 +104,7 @@
return self._fifo.pop(0)
except IndexError:
raise StopIteration
-
+
class MessageWriter(object):
"""Write messages to a channel
"""
Modified: pymoul/trunk/src/moul/chatrelay/ircclient.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-24 22:50:20 UTC (rev 294)
+++ pymoul/trunk/src/moul/chatrelay/ircclient.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -5,7 +5,7 @@
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@@ -68,7 +68,7 @@
reader = None
writer = None
interval = 5
-
+
def __init__(self, nickname, channel, realname=None, username=None,
serverpasswd=None, nickpasswd=None, adminpasswd=None):
"""
@@ -80,7 +80,7 @@
self.password = serverpasswd
self.nickpasswd = nickpasswd
self.adminpasswd = adminpasswd
-
+
self.loop = LoopingCall(self.checkLogfile)
self.identified = []
@@ -95,7 +95,7 @@
def checkLogfile(self):
for line in iter(self.reader):
self.writer.log(line)
-
+
def start(self):
#if not self.reader.isOpen:
# return
@@ -117,10 +117,10 @@
def joined(self, channel):
log.msg("I have joined", channel)
-
+
def left(self, channel):
log.msg("I have left", channel)
-
+
def kickedFrom(self, channel, kicker, message):
log.msg("I have been kicked from %s by %s: %s" %
(channel, kicker, message))
@@ -172,7 +172,7 @@
#self.say(channel, "count %d" % self.counter)
#self.counter += 1
-
+
def reply(self, dest, message):
# maybe self.notice(dest, message) instead?
self.msg(dest, message)
@@ -210,7 +210,7 @@
commands.append(name)
commands.sort()
return commands
-
+
@usage("help <command> - Give help for <command>")
def command_HELP(self, user, reply, args):
args = args.split()
@@ -272,7 +272,7 @@
readerClass = LogFileReader
writerClass = MessageWriter
formatter = MOULLogFormatter(skipprivate=False, onlyimportant=False)
-
+
def __init__(self, nickname, channel, realname=None, username=None,
serverpasswd=None, nickpasswd=None, adminpasswd=None):
"""
@@ -289,7 +289,7 @@
d = self.__dict__.copy()
del d['p']
return d
-
+
def shutdown(self):
self.shuttingDown = True
if self.p:
Added: pymoul/trunk/src/moul/chatrelay/parser.py
===================================================================
--- pymoul/trunk/src/moul/chatrelay/parser.py (rev 0)
+++ pymoul/trunk/src/moul/chatrelay/parser.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -0,0 +1,27 @@
+from zope.interface import implements
+
+from moul.file.chatlog import ChatlogParser
+
+from moul.chatrelay.interfaces import IInputParser
+
+__all__ = [obj for obj in globals() if IInputParser.isImplementedBy(obj)]
+
+class NullParser(object):
+ implements(IInputParser)
+ name = 'Null parser'
+
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def parse(self, line):
+ return line, {}
+
+class MOULChatlogParser(ChatlogParser):
+ implements(IInputParser)
+ name = 'MOUL chatlog parser'
+
+ def __init__(self, year):
+ self.setYear(year)
+
+ def setYear(self, year):
+ self._year = int(year)
Property changes on: pymoul/trunk/src/moul/chatrelay/parser.py
___________________________________________________________________
Name: svn:keywords
+ 'Id Revision'
Name: svn:eol-style
+ native
Modified: pymoul/trunk/src/moul/file/chatlog.py
===================================================================
--- pymoul/trunk/src/moul/file/chatlog.py 2007-05-24 22:50:20 UTC (rev 294)
+++ pymoul/trunk/src/moul/file/chatlog.py 2007-05-28 16:53:00 UTC (rev 295)
@@ -53,17 +53,9 @@
CHAT_ACTION = 1 << 6
# users
-USER_CYAN = [
- 'gregbert', 'greydragon', 'Rand Miller', 'ResEng B. Mathias',
- 'ResEng B.Dreschel', 'ResEng C. Lambert', 'ResEng KJohnson',
- 'ResEng 102', 'ResEng 233',
- ]
-USER_DRC = [
- 'Cate Alexander', 'Dr. Kodama', 'Marie Sutherland', 'Michael Engberg',
- 'Victor Laxman', 'Wheely', 'Douglas Sharper', 'Phil Henderson',
- 'Nick White'
- ]
-
+USER_CYAN = ['gregbert', 'greydragon']
+USER_DRC = ['Marie Sutherland', 'Douglas Sharper', 'Nick White',
+ 'Dr. Kodama', 'Victor Laxman', 'Michael Engberg']
USER_IMPORTANT = USER_CYAN + USER_DRC
RE_FLAGS = re.LOCALE
@@ -357,7 +349,7 @@
New idea, new design
"""
- def __init__(self, iterable, year=2007):
+ def __init__(self, iterable=[], year=2007):
self._iterable = iterable
self._year = year # XXX
@@ -366,58 +358,42 @@
if mo is None:
return ChatLine(line, (1970, 1, 1, 0, 0, 0), CHAT_UNKNOWN)
d = mo.groupdict()
- date = (self._year, int(d['M']), int(d['D']),
- int(d['h']), int(d['m']), int(d['s']))
- typ = CHAT_UNKNOWN
+ dt = (self._year, int(d['M']), int(d['D']),
+ int(d['h']), int(d['m']), int(d['s']))
msg = d['msg']
- info = {}
- important = False
+ info = {'type' : CHAT_UNKNOWN, 'datetime' : dt, 'important' : False}
if len(d['space']) == 2:
- typ = CHAT_MSG
mo = MSG_RE.match(msg)
if mo is None:
- return ChatLine(msg, dte, CHAT_UNKNOWN)
- info = mo.groupdict()
+ return msg, info
+ info['type'] = CHAT_MSG
+ info.update(mo.groupdict())
else:
if msg == CHATLOG_START:
- typ = CHAT_START
+ info['type'] = CHAT_START
elif msg == CHATLOG_STOP:
- typ = CHAT_STOP
+ info['type'] = CHAT_STOP
else:
for t, r in ((CHAT_PRIVMSGFROM, PRIVMSGFROM_RE),
(CHAT_PRIVMSGTO, PRIVMSGTO_RE),
(CHAT_ERROR, ERROR_RE)):
mo = r.match(msg)
if mo:
- typ = t
- info = mo.groupdict()
+ info['type'] = t
+ info.update(mo.groupdict())
break
- if typ == CHAT_UNKNOWN: # XXX check this
- typ = CHAT_ACTION
+ if info['type'] == CHAT_UNKNOWN: # XXX check this
+ info['type'] = CHAT_ACTION
for user in USER_IMPORTANT:
if user in msg:
- important = True
+ info['important'] = True
user = info.get('user', None)
if user:
if user in USER_IMPORTANT:
- important = True
- return ChatLine(msg, date, typ, important, info)
+ info['important'] = True
+ return msg, info
def __iter__(self):
for line in self._iterable:
yield self.parse(line)
-
-class ChatLine(unicode):
- __slots__ = ('datetime', 'typ', 'important', 'info')
-
- def __new__(cls, ustr, datetime, typ=None, important=False, info={}):
- self = unicode.__new__(cls, ustr)
- self.datetime = datetime
- self.typ = typ
- self.important = important
- self.info = info
- return self
-
- def asDatetime(self):
- return datetime(*self.date)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|