[Pymoul-svn] SF.net SVN: pymoul: [41] pymoul/trunk
Status: Alpha
Brought to you by:
tiran
|
From: <ti...@us...> - 2007-01-17 12:52:53
|
Revision: 41
http://pymoul.svn.sourceforge.net/pymoul/?rev=41&view=rev
Author: tiran
Date: 2007-01-17 04:52:49 -0800 (Wed, 17 Jan 2007)
Log Message:
-----------
* Disabled some code in time.cavern that is no longer required
* Revamped ping tests and added some useful stuff to ServerList like iter() and len()
Modified Paths:
--------------
pymoul/trunk/Makefile
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/server/ping.py
pymoul/trunk/src/moul/server/tests/test_ping.py
pymoul/trunk/src/moul/time/cavern.py
Modified: pymoul/trunk/Makefile
===================================================================
--- pymoul/trunk/Makefile 2007-01-17 11:29:30 UTC (rev 40)
+++ pymoul/trunk/Makefile 2007-01-17 12:52:49 UTC (rev 41)
@@ -9,7 +9,7 @@
inplace:
$(PYTHON) setup.py $(SETUPFLAGS) build_ext -i
-build:
+build: compileui
$(PYTHON) setup.py $(SETUPFLAGS) build
py2exe:
@@ -18,13 +18,16 @@
bdist_egg:
$(PYTHON) setup.py $(SETUPFLAGS) bdist_egg
-run:
+run: compileui
$(PYTHON) src/moul/qt/moulqt.py
-test_build: build
+compileui:
+ $(PYTHON) compileui.py
+
+test_build: build compileui
$(PYTHON) test.py $(TESTFLAGS) $(TESTOPTS)
-test_inplace:
+test_inplace: compileui
$(PYTHON) test.py $(TESTFLAGS) $(TESTOPTS)
ftest_build: build
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-01-17 11:29:30 UTC (rev 40)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-01-17 12:52:49 UTC (rev 41)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'src\moul\qt\ui\mainwindow.ui'
#
-# Created: Wed Jan 17 01:43:35 2007
+# Created: Wed Jan 17 13:36:40 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -27,6 +27,13 @@
self.centralwidget.setEnabled(True)
self.centralwidget.setObjectName("centralwidget")
+ self.label = QtGui.QLabel(self.centralwidget)
+ self.label.setGeometry(QtCore.QRect(15,10,430,58))
+ self.label.setFrameShape(QtGui.QFrame.StyledPanel)
+ self.label.setFrameShadow(QtGui.QFrame.Sunken)
+ self.label.setPixmap(QtGui.QPixmap(":/resources/moul_logo.png"))
+ self.label.setObjectName("label")
+
self.horizontalLayout = QtGui.QWidget(self.centralwidget)
self.horizontalLayout.setGeometry(QtCore.QRect(60,70,341,31))
self.horizontalLayout.setObjectName("horizontalLayout")
@@ -58,13 +65,6 @@
self.pushButton.setObjectName("pushButton")
self.hboxlayout.addWidget(self.pushButton)
- self.label = QtGui.QLabel(self.centralwidget)
- self.label.setGeometry(QtCore.QRect(15,10,430,58))
- self.label.setFrameShape(QtGui.QFrame.StyledPanel)
- self.label.setFrameShadow(QtGui.QFrame.Sunken)
- self.label.setPixmap(QtGui.QPixmap(":/resources/moul_logo.png"))
- self.label.setObjectName("label")
-
self.tabWidget = QtGui.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(5,100,450,375))
self.tabWidget.setTabPosition(QtGui.QTabWidget.North)
@@ -283,10 +283,6 @@
self.tab_time = QtGui.QWidget()
self.tab_time.setObjectName("tab_time")
- self.gb_dnitime = QtGui.QGroupBox(self.tab_time)
- self.gb_dnitime.setGeometry(QtCore.QRect(10,130,431,211))
- self.gb_dnitime.setObjectName("gb_dnitime")
-
self.gb_caverntime = QtGui.QGroupBox(self.tab_time)
self.gb_caverntime.setGeometry(QtCore.QRect(10,10,431,111))
self.gb_caverntime.setObjectName("gb_caverntime")
@@ -301,6 +297,9 @@
self.gridlayout.setObjectName("gridlayout")
self.dt_cavern = QtGui.QDateTimeEdit(self.gridLayout)
+ self.dt_cavern.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape(0)))
+ self.dt_cavern.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.dt_cavern.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
self.dt_cavern.setReadOnly(True)
self.dt_cavern.setButtonSymbols(QtGui.QAbstractSpinBox.UpDownArrows)
self.dt_cavern.setObjectName("dt_cavern")
@@ -319,6 +318,8 @@
self.gridlayout.addWidget(self.label_5,1,0,1,1)
self.dt_pacific = QtGui.QDateTimeEdit(self.gridLayout)
+ self.dt_pacific.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.dt_pacific.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
self.dt_pacific.setReadOnly(True)
self.dt_pacific.setButtonSymbols(QtGui.QAbstractSpinBox.UpDownArrows)
self.dt_pacific.setObjectName("dt_pacific")
@@ -327,8 +328,29 @@
self.lb_pacific_utc = QtGui.QLabel(self.gridLayout)
self.lb_pacific_utc.setObjectName("lb_pacific_utc")
self.gridlayout.addWidget(self.lb_pacific_utc,1,2,1,1)
+
+ self.gb_dnitime = QtGui.QGroupBox(self.tab_time)
+ self.gb_dnitime.setGeometry(QtCore.QRect(10,130,431,211))
+ self.gb_dnitime.setObjectName("gb_dnitime")
self.tabWidget.addTab(self.tab_time,"")
+ self.tab = QtGui.QWidget()
+ self.tab.setObjectName("tab")
+
+ self.gb_servers = QtGui.QGroupBox(self.tab)
+ self.gb_servers.setGeometry(QtCore.QRect(10,0,421,341))
+ self.gb_servers.setObjectName("gb_servers")
+
+ self.but_ping = QtGui.QPushButton(self.gb_servers)
+ self.but_ping.setGeometry(QtCore.QRect(330,310,75,24))
+ self.but_ping.setObjectName("but_ping")
+
+ self.text_ping = QtGui.QTextEdit(self.gb_servers)
+ self.text_ping.setGeometry(QtCore.QRect(10,20,401,271))
+ self.text_ping.setReadOnly(True)
+ self.text_ping.setObjectName("text_ping")
+ self.tabWidget.addTab(self.tab,"")
+
self.tab_4 = QtGui.QWidget()
self.tab_4.setObjectName("tab_4")
@@ -350,7 +372,7 @@
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
- self.tabWidget.setCurrentIndex(0)
+ self.tabWidget.setCurrentIndex(2)
QtCore.QObject.connect(self.buttonbox_rresavcl,QtCore.SIGNAL("rejected()"),MainWindow.close)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
@@ -376,13 +398,20 @@
self.label_7.setText(QtGui.QApplication.translate("MainWindow", "Ultra", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_graphics), QtGui.QApplication.translate("MainWindow", "Graphis", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_audio), QtGui.QApplication.translate("MainWindow", "Audio", 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))
self.label_4.setText(QtGui.QApplication.translate("MainWindow", "Cavern time:", None, QtGui.QApplication.UnicodeUTF8))
self.lb_cavern_utc.setText(QtGui.QApplication.translate("MainWindow", "UTC", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Pacific time:", None, QtGui.QApplication.UnicodeUTF8))
self.lb_pacific_utc.setText(QtGui.QApplication.translate("MainWindow", "UTC", 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_time), QtGui.QApplication.translate("MainWindow", "Time", None, QtGui.QApplication.UnicodeUTF8))
+ self.gb_servers.setTitle(QtGui.QApplication.translate("MainWindow", "Ping servers", None, QtGui.QApplication.UnicodeUTF8))
+ self.but_ping.setText(QtGui.QApplication.translate("MainWindow", "Ping", None, QtGui.QApplication.UnicodeUTF8))
+ self.text_ping.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;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Servers", None, QtGui.QApplication.UnicodeUTF8))
self.label_6.setText(QtGui.QApplication.translate("MainWindow", "pyMoul tools", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), 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-01-17 11:29:30 UTC (rev 40)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-01-17 12:52:49 UTC (rev 41)
@@ -31,6 +31,28 @@
<property name="enabled" >
<bool>true</bool>
</property>
+ <widget class="QLabel" name="label" >
+ <property name="geometry" >
+ <rect>
+ <x>15</x>
+ <y>10</y>
+ <width>430</width>
+ <height>58</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="pixmap" >
+ <pixmap resource="moulqt.qrc" >:/resources/moul_logo.png</pixmap>
+ </property>
+ </widget>
<widget class="QWidget" name="horizontalLayout" >
<property name="geometry" >
<rect>
@@ -78,28 +100,6 @@
</item>
</layout>
</widget>
- <widget class="QLabel" name="label" >
- <property name="geometry" >
- <rect>
- <x>15</x>
- <y>10</y>
- <width>430</width>
- <height>58</height>
- </rect>
- </property>
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Sunken</enum>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="pixmap" >
- <pixmap resource="moulqt.qrc" >:/resources/moul_logo.png</pixmap>
- </property>
- </widget>
<widget class="QTabWidget" name="tabWidget" >
<property name="geometry" >
<rect>
@@ -113,7 +113,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex" >
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="tab_graphics" >
<attribute name="title" >
@@ -545,19 +545,6 @@
<attribute name="title" >
<string>Time</string>
</attribute>
- <widget class="QGroupBox" name="gb_dnitime" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>130</y>
- <width>431</width>
- <height>211</height>
- </rect>
- </property>
- <property name="title" >
- <string>D'ni time</string>
- </property>
- </widget>
<widget class="QGroupBox" name="gb_caverntime" >
<property name="geometry" >
<rect>
@@ -588,6 +575,15 @@
</property>
<item row="0" column="1" >
<widget class="QDateTimeEdit" name="dt_cavern" >
+ <property name="cursor" >
+ <cursor>0</cursor>
+ </property>
+ <property name="focusPolicy" >
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="contextMenuPolicy" >
+ <enum>Qt::NoContextMenu</enum>
+ </property>
<property name="readOnly" >
<bool>true</bool>
</property>
@@ -619,6 +615,12 @@
</item>
<item row="1" column="1" >
<widget class="QDateTimeEdit" name="dt_pacific" >
+ <property name="focusPolicy" >
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="contextMenuPolicy" >
+ <enum>Qt::NoContextMenu</enum>
+ </property>
<property name="readOnly" >
<bool>true</bool>
</property>
@@ -637,7 +639,70 @@
</layout>
</widget>
</widget>
+ <widget class="QGroupBox" name="gb_dnitime" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>130</y>
+ <width>431</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>D'ni time</string>
+ </property>
+ </widget>
</widget>
+ <widget class="QWidget" name="tab" >
+ <attribute name="title" >
+ <string>Servers</string>
+ </attribute>
+ <widget class="QGroupBox" name="gb_servers" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>0</y>
+ <width>421</width>
+ <height>341</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>Ping servers</string>
+ </property>
+ <widget class="QPushButton" name="but_ping" >
+ <property name="geometry" >
+ <rect>
+ <x>330</x>
+ <y>310</y>
+ <width>75</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Ping</string>
+ </property>
+ </widget>
+ <widget class="QTextEdit" name="text_ping" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>401</width>
+ <height>271</height>
+ </rect>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ <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:'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;"></p></body></html></string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
<widget class="QWidget" name="tab_4" >
<attribute name="title" >
<string>About</string>
Modified: pymoul/trunk/src/moul/server/ping.py
===================================================================
--- pymoul/trunk/src/moul/server/ping.py 2007-01-17 11:29:30 UTC (rev 40)
+++ pymoul/trunk/src/moul/server/ping.py 2007-01-17 12:52:49 UTC (rev 41)
@@ -17,30 +17,6 @@
#
"""Server ping
->>> server = Server(SERVER_LIST[0], PORT)
->>> result = server.dns()
->>> isinstance(result, float)
-True
->>> result = server.portping()
->>> isinstance(result, float)
-True
-
->>> server = Server('bogus.nonworking.example.foo', PORT)
->>> result = server.dns()
->>> isinstance(result, socket.gaierror)
-True
-
->>> server = Server(name=SERVER_LIST[0], port=12345, timeout=1.0)
->>> result = server.portping()
->>> isinstance(result, socket.timeout)
-True
-
->>> serverlist = ServerList(names=SERVER_LIST, port=PORT, timeout=1.0)
->>> for name, stat in serverlist.dns():
-... print name, stat
->>> for name, stat in serverlist.portping():
-... print name, stat
-
"""
import socket
from time import time
@@ -88,7 +64,7 @@
if self._ip is None:
self.dns()
if self._ip is False:
- return
+ return False
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(self._timeout)
@@ -133,3 +109,9 @@
def portping(self):
for server in self._servers:
yield server.name, server.portping()
+
+ def __iter__(self):
+ return iter(self._servers)
+
+ def __len__(self):
+ return len(self._servers)
Modified: pymoul/trunk/src/moul/server/tests/test_ping.py
===================================================================
--- pymoul/trunk/src/moul/server/tests/test_ping.py 2007-01-17 11:29:30 UTC (rev 40)
+++ pymoul/trunk/src/moul/server/tests/test_ping.py 2007-01-17 12:52:49 UTC (rev 41)
@@ -24,10 +24,40 @@
import unittest
from doctest import DocTestSuite
-import moul.server.ping
+from moul.server.ping import Server
+from moul.server.ping import ServerList
+from moul.server.ping import isError
+from moul.server.serverlist import SERVER_LIST
+from moul.server.serverlist import PORT
+class PingServerTest(unittest.TestCase):
+
+ def test_ping_working(self):
+ server = Server(SERVER_LIST[0], PORT)
+ result = server.dns()
+ self.failUnless(isinstance(result, float))
+ result = server.portping()
+ self.failUnless(isinstance(result, float))
+
+ def test_ping_bogus(self):
+ server = Server('bogus.nonworking.example.foo', PORT)
+ result = server.dns()
+ self.failUnless(isError(result))
+ result = server.portping()
+ self.failUnless(result is False)
+
+ def test_iterlist(self):
+ names = ['server1', 'server2']
+ sl = ServerList(names, PORT)
+ self.failUnlessEqual(len(sl), 2)
+ servers = []
+ for server in sl:
+ servers.append(server.name)
+ self.failUnlessEqual(servers, names)
+
def test_suite():
return unittest.TestSuite((
+ unittest.makeSuite(PingServerTest),
DocTestSuite('moul.server.ping'),
))
Modified: pymoul/trunk/src/moul/time/cavern.py
===================================================================
--- pymoul/trunk/src/moul/time/cavern.py 2007-01-17 11:29:30 UTC (rev 40)
+++ pymoul/trunk/src/moul/time/cavern.py 2007-01-17 12:52:49 UTC (rev 41)
@@ -21,7 +21,7 @@
__version__ = "$Id$"
__revision__ = "$Revision$"
-__all__ = ['TIMEZONE_NAMES', 'CavernTime']
+__all__ = ['CavernTime']
from datetime import datetime
@@ -30,43 +30,46 @@
from pytz import timezone
from pytz import utc as UTC
-SUPPORTED_TZ = ('America', 'Canada', 'Etc', 'Europe', 'US')
-ADDITIONAL_TZ = ('GMT', 'UTC')
+## not used in the current version
+#SUPPORTED_TZ = ('America', 'Canada', 'Etc', 'Europe', 'US')
+#ADDITIONAL_TZ = ('GMT', 'UTC')
+#
+#def _listSupported(tz_list):
+# supported = []
+# unsupported = []
+# for tz in tz_list:
+# if tz.find('/') == -1:
+# if tz in ADDITIONAL_TZ:
+# supported.append(tz)
+# else:
+# unsupported.append(tz)
+# continue
+# split = tz.split('/')
+# if len(split) > 2:
+# continue
+# prefix, postfix = tz.split('/')[:2]
+# if prefix in SUPPORTED_TZ:
+# supported.append(tz)
+# else:
+# unsupported.append(tz)
+# supported.sort()
+# unsupported.sort()
+# return supported, unsupported
+#
+## not used in the current version
+#TIMEZONE_NAMES, UNSUPPORTED = _listSupported(all_timezones)
-def _listSupported(tz_list):
- supported = []
- unsupported = []
- for tz in tz_list:
- if tz.find('/') == -1:
- if tz in ADDITIONAL_TZ:
- supported.append(tz)
- else:
- unsupported.append(tz)
- continue
- split = tz.split('/')
- if len(split) > 2:
- continue
- prefix, postfix = tz.split('/')[:2]
- if prefix in SUPPORTED_TZ:
- supported.append(tz)
- else:
- unsupported.append(tz)
- supported.sort()
- unsupported.sort()
- return supported, unsupported
-
-TIMEZONE_NAMES, UNSUPPORTED = _listSupported(all_timezones)
-
# Cyan HQ is near Spokane / Washington
# Cavern time is Mountain Time Zone (MDT) with daylight savings (MST)
CAVERN_TZ_NAME = 'US/Mountain' # MST / MDT
CAVERN_TZ = timezone(CAVERN_TZ_NAME)
+# The support is using PST (PDT)
PACIFIC_TZ_NAME = 'US/Pacific' # PST / PDT
PACIFIC_TZ = timezone(PACIFIC_TZ_NAME)
def diffTD(td1, td2):
- """Difference of two objects -> int
+ """Difference of two time delta objects -> int
>>> from datetime import timedelta
>>> type(diffTD(timedelta(0, 3600), timedelta(0, -3600)))
@@ -150,12 +153,12 @@
True
>>> del pst
- >>> 'UTC' in CavernTime.timezones
- True
- >>> 'UTC' in ct.timezones
- True
+ #>>> 'UTC' in CavernTime.timezones
+ #True
+ #>>> 'UTC' in ct.timezones
+ #True
"""
- timezones = TIMEZONE_NAMES
+ # timezones = TIMEZONE_NAMES
_cavern = CAVERN_TZ
_pacific = PACIFIC_TZ
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|