dabo Commit
Revision 5128
Date: 2009-03-14 13:13:36 -0700 (Sat, 14 Mar 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5128
Changed:
A trunk/springboard/
A trunk/springboard/biz/
A trunk/springboard/biz/__init__.py
A trunk/springboard/db/
A trunk/springboard/db/__init__.py
A trunk/springboard/main.py
A trunk/springboard/reports/
A trunk/springboard/reports/__init__.py
A trunk/springboard/resources/
A trunk/springboard/resources/__init__.py
A trunk/springboard/setup.py
A trunk/springboard/springboard.icns
A trunk/springboard/test/
A trunk/springboard/test/__init__.py
A trunk/springboard/ui/
A trunk/springboard/ui/__init__.py
A trunk/springboard/ui/springboard-code.py
A trunk/springboard/ui/springboard.cdxml
Log:
Initial import of Springboard code into the repository.
Diff:
Added: trunk/springboard/biz/__init__.py
===================================================================
--- trunk/springboard/biz/__init__.py (rev 0)
+++ trunk/springboard/biz/__init__.py 2009-03-14 20:13:36 UTC (rev 5128)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+######
+# In order for Dabo to 'see' classes in your biz directory, add an
+# import statement here for each class. E.g., if you have a file named
+# 'MyClasses.py' in this directory, and it defines two classes named
'FirstClass'
+# and 'SecondClass', add these lines:
+#
+# from MyClass import FirstClass
+# from MyClass import SecondClass
+#
+# Now you can refer to these classes as: self.Application.biz.FirstClass and
+# self.Application.biz.SecondClass
+######
+
Added: trunk/springboard/db/__init__.py
===================================================================
--- trunk/springboard/db/__init__.py (rev 0)
+++ trunk/springboard/db/__init__.py 2009-03-14 20:13:36 UTC (rev 5128)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+######
+# In order for Dabo to 'see' classes in your db directory, add an
+# import statement here for each class. E.g., if you have a file named
+# 'MyClasses.py' in this directory, and it defines two classes named
'FirstClass'
+# and 'SecondClass', add these lines:
+#
+# from MyClass import FirstClass
+# from MyClass import SecondClass
+#
+# Now you can refer to these classes as: self.Application.db.FirstClass and
+# self.Application.db.SecondClass
+######
+
Added: trunk/springboard/main.py
===================================================================
--- trunk/springboard/main.py (rev 0)
+++ trunk/springboard/main.py 2009-03-14 20:13:36 UTC (rev 5128)
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import dabo
+dabo.ui.loadUI("wx")
+from dabo.lib import utils
+
+if __name__ == "__main__":
+ app = dabo.dApp()
+ app.BasePrefKey = "dabo.springboard"
+ app.MainFormClass = "springboard.cdxml"
+ app.PreferenceManager.local_storage_dir =
utils.getUserAppDataDirectory()
+
+ app.start()
Property changes on: trunk/springboard/main.py
___________________________________________________________________
Name: svn:executable
+
Added: trunk/springboard/reports/__init__.py
===================================================================
--- trunk/springboard/reports/__init__.py (rev 0)
+++ trunk/springboard/reports/__init__.py 2009-03-14 20:13:36 UTC (rev
5128)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+######
+# In order for Dabo to 'see' classes in your reports directory, add an
+# import statement here for each class. E.g., if you have a file named
+# 'MyClasses.py' in this directory, and it defines two classes named
'FirstClass'
+# and 'SecondClass', add these lines:
+#
+# from MyClass import FirstClass
+# from MyClass import SecondClass
+#
+# Now you can refer to these classes as: self.Application.reports.FirstClass
and
+# self.Application.reports.SecondClass
+######
+
Added: trunk/springboard/resources/__init__.py
===================================================================
--- trunk/springboard/resources/__init__.py (rev 0)
+++ trunk/springboard/resources/__init__.py 2009-03-14 20:13:36 UTC (rev
5128)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+######
+# In order for Dabo to 'see' classes in your resources directory, add an
+# import statement here for each class. E.g., if you have a file named
+# 'MyClasses.py' in this directory, and it defines two classes named
'FirstClass'
+# and 'SecondClass', add these lines:
+#
+# from MyClass import FirstClass
+# from MyClass import SecondClass
+#
+# Now you can refer to these classes as: self.Application.resources.FirstClass
and
+# self.Application.resources.SecondClass
+######
+
Added: trunk/springboard/setup.py
===================================================================
--- trunk/springboard/setup.py (rev 0)
+++ trunk/springboard/setup.py 2009-03-14 20:13:36 UTC (rev 5128)
@@ -0,0 +1,83 @@
+"""
+This is a setup.py script generated by py2applet
+
+Usage:
+ python setup.py py2app
+"""
+
+from setuptools import setup
+import sys
+import os
+import glob
+import dabo
+import dabo.icons
+
+DATA_FILES = []
+plat = sys.platform
+if plat == "darwin":
+ # OS X
+ OPTIONS = {"argv_emulation": True, "excludes": ["psycopg2", "MySQLdb",
"numpy"],
+ "iconfile": "springboard.icns"}
+elif plat == "win32":
+ # Windows
+ import py2exe
+ OPTIONS = {"excludes": ["psycopg2", "MySQLdb", "numpy", "kinterbasdb"]}
+
+
+daboDir = os.path.split(dabo.__file__)[0]
+
+# Find the location of the dabo icons:
+iconDir = os.path.split(dabo.icons.__file__)[0]
+iconSubDirs = []
+def getIconSubDir(arg, dirname, fnames):
+ if os.path.split(dirname)[1] in (".svn", "cards"):
+ return
+ icons = glob.glob(os.path.join(dirname, "*.png"))
+ if icons:
+ subdir = (os.path.join("resources", dirname[len(arg)+1:]),
icons)
+ iconSubDirs.append(subdir)
+os.path.walk(iconDir, getIconSubDir, iconDir)
+DATA_FILES.extend(iconSubDirs)
+
+# locales:
+localeDir = os.path.join(daboDir, "locale")
+locales = []
+def getLocales(arg, dirname, fnames):
+ if os.path.split(dirname)[1] in (".svn", ):
+ return
+ mo_files = tuple(glob.glob(os.path.join(dirname, "*.mo")))
+ if mo_files:
+ subdir = os.path.join("locale", dirname[len(arg)+1:])
+ locales.append((subdir, mo_files))
+os.path.walk(localeDir, getLocales, localeDir)
+DATA_FILES.extend(locales)
+
+
+# Application files. Include all but .pyc
+appDir = os.getcwd()
+appFiles = []
+def getAppFiles(arg, dirname, fnames):
+ if os.path.split(dirname)[1] in (".svn", "supplemental", "test"):
+ return
+ currnames = glob.glob(os.path.join(dirname, "*"))
+ filtered = tuple([nm for nm in currnames
+ if not nm.endswith(".pyc")
+ and not os.path.isdir(nm)])
+ if filtered:
+ subdir = dirname[len(arg)+1:]
+ appFiles.append((subdir, filtered))
+os.path.walk(appDir, getAppFiles, appDir)
+DATA_FILES.extend(appFiles)
+
+setup(
+ data_files=DATA_FILES,
+ version = "1.0",
+ description = "Dabo Springboard",
+ name = "dabo_springboard",
+ # targets to build
+ app = ["main.py"],
+ #windows = [{"script": "tweezer.py", "icon_resources": [(0,
"tweezer.ico")]}],
+ #console = [{"script": "tweezer.py", "icon_resources": [(0,
"tweezer.ico")]}],
+ options={"py2app": OPTIONS,
+ "py2exe": OPTIONS},
+)
Added: trunk/springboard/springboard.icns
===================================================================
(Binary files differ)
Property changes on: trunk/springboard/springboard.icns
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/springboard/test/__init__.py
===================================================================
--- trunk/springboard/test/__init__.py (rev 0)
+++ trunk/springboard/test/__init__.py 2009-03-14 20:13:36 UTC (rev 5128)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+######
+# In order for Dabo to 'see' classes in your test directory, add an
+# import statement here for each class. E.g., if you have a file named
+# 'MyClasses.py' in this directory, and it defines two classes named
'FirstClass'
+# and 'SecondClass', add these lines:
+#
+# from MyClass import FirstClass
+# from MyClass import SecondClass
+#
+# Now you can refer to these classes as: self.Application.test.FirstClass and
+# self.Application.test.SecondClass
+######
+
Added: trunk/springboard/ui/__init__.py
===================================================================
--- trunk/springboard/ui/__init__.py (rev 0)
+++ trunk/springboard/ui/__init__.py 2009-03-14 20:13:36 UTC (rev 5128)
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+######
+# In order for Dabo to 'see' classes in your ui directory, add an
+# import statement here for each class. E.g., if you have a file named
+# 'MyClasses.py' in this directory, and it defines two classes named
'FirstClass'
+# and 'SecondClass', add these lines:
+#
+# from MyClass import FirstClass
+# from MyClass import SecondClass
+#
+# Now you can refer to these classes as: self.Application.ui.FirstClass and
+# self.Application.ui.SecondClass
+######
+
Added: trunk/springboard/ui/springboard-code.py
===================================================================
--- trunk/springboard/ui/springboard-code.py (rev 0)
+++ trunk/springboard/ui/springboard-code.py 2009-03-14 20:13:36 UTC (rev
5128)
@@ -0,0 +1,196 @@
+# -*- coding: utf-8 -*-
+### Dabo Class Designer code. You many freely edit the code,
+### but do not change the comments containing:
+### 'Dabo Code ID: XXXX',
+### as these are needed to link the code to the objects.
+
+import os
+import time
+import urlparse
+import dabo
+from dabo.lib.RemoteConnector import RemoteConnector
+from dabo.dLocalize import _
+
+
+## *!* ## Dabo Code ID: dTextBox-dPanel
+def onKeyChar(self, evt):
+ if evt.keyCode == dabo.ui.dKeys.key_Return:
+ mthd = self.Form.connectToServer
+ else:
+ mthd = self.Form.completeURL
+ dabo.ui.callAfter(mthd, key=evt.keyCode)
+
+
+
+## *!* ## Dabo Code ID: dListBox-dPanel
+def afterInit(self):
+ self.bindKey("enter", self.onEnter)
+ self.bindEvent(dabo.dEvents.MouseLeftDoubleClick, self.onEnter)
+
+
+def onEnter(self, evt):
+ self.Form.runSelection()
+
+
+
+## *!* ## Dabo Code ID: dButton-dPanel-553
+def afterInit(self):
+ self.DynamicEnabled = self.Form.hasSelection
+
+
+def onHit(self, evt):
+ self.Form.runSelection()
+
+
+
+## *!* ## Dabo Code ID: dForm-top
+def _getAddress(self):
+ try:
+ return self.txtAddress.Value
+ except AttributeError:
+ return None
+
+
+def _runApp(self, path):
+ app = os.path.split(path)[1]
+ self.busy = dabo.ui.busyInfo(_("Launching the '%s' application...") %
app)
+ appdir = self._proxy.syncFiles(path)
+ if appdir:
+ os.chdir(appdir)
+ # We'll assume that the main program is 'main.py'
+ main = [fname for fname in ("main.py", "%s.py" % app, "go.sh")
+ if os.path.exists(fname)]
+ if main:
+ # Use the first, in case there are more than one 'main' program
+ pid, proc = dabo.ui.spawnProcess("/usr/bin/python %s" %
main[0], handler=self)
+ self._processes.append(proc)
+
+ def setNone():
+ self.busy = None
+ dabo.ui.callAfterInterval(2000, setNone)
+
+
+# def onIdle(self, evt):
+# for proc in self._processes:
+# if not proc:
+# continue
+# else:
+# print "PROC", proc.read()
+
+def onProcTermintated(self, proc, pid, status):
+ self._processes.remove(proc)
+
+
+def afterInit(self):
+ self._escChar = "|||"
+ self._proxy = RemoteConnector(self)
+ self._availableApps = []
+ self._processes = []
+
+
+def afterInitAll(self):
+ self.mrus = []
+ recent = None
+ choices = []
+ prefMRU = self.PreferenceManager.mru
+ mrus = prefMRU.getPrefKeys()
+ if mrus:
+ mrus.sort()
+ while mrus:
+ mruKey = mrus.pop()
+ mru = prefMRU.get(mruKey)
+ if isinstance(mru, basestring):
+ choices.append(mru)
+ if not recent:
+ recent = mru
+ self.mrus = choices
+ if not recent:
+ # First time; add a default value
+ recent = "http://"
+ self.txtAddress.Value = recent
+ self.update()
+ dabo.ui.callAfter(self.initialFocus)
+
+
+def initialFocus(self):
+ txt = self.txtAddress
+ txt.setFocus()
+ addr = txt.Value
+ slashpos = addr.find("//")
+ if slashpos >= 0:
+ txt.SelectionStart = slashpos + 2
+ txt.SelectionEnd = len(addr)
+
+
+def completeURL(self, key=None):
+ deleting = key in (dabo.ui.dKeys.key_Back, dabo.ui.dKeys.key_Delete)
+ txt = self.txtAddress
+ addr = txt.Value
+ if deleting:
+ addr = addr[:-1]
+ addrLen = len(addr)
+ matches = [mru for mru in self.mrus
+ if mru.startswith(addr)]
+ if matches and not deleting:
+ txt.Value = matches[0]
+ txt.SelectionStart = addrLen
+ txt.SelectionEnd = 999
+
+
+def connectToServer(self, key=None):
+ addr = self.Address
+ try:
+ result = self._proxy.launch(url=addr)
+ except StandardError, e:
+ print "CONNECTION ERR", type(e), e
+ return
+ if result:
+ # Add to MRUS
+ self._addToMRUs(addr)
+ if isinstance(result, basestring) and
result.startswith("Error"):
+ # Error
+ dabo.ui.stop(result, "Server Error")
+ elif isinstance(result, list):
+ self.appList.Choices = result
+ self.appList.PositionValue = 0
+ self.update()
+ dabo.ui.callAfter(self.appList.setFocus)
+ self.refresh()
+ elif isinstance(result, basestring) and
result.startswith("404"):
+ dabo.ui.stop(_("%s\nAre you sure that's a Dabo
application server?") % addr, result)
+ else:
+ dabo.ui.stop(_("Received this message from the server:
%s") % str(result), _("Server Error"))
+
+
+def _addToMRUs(self, addr):
+ # Add to MRU
+ stamp = "%s" % int(round(time.time() * 100, 0))
+ prefMRU = self.PreferenceManager.mru
+ scheme, netloc, path, parameters, query, fragment =
urlparse.urlparse(addr)
+ stored = "%s://%s" % (scheme, netloc)
+ prefMRU.deleteByValue(stored)
+ prefMRU.setValue(stamp, stored)
+
+def hasSelection(self):
+ return bool(self.appList.Choices and self.appList.Value)
+
+
+def runSelection(self):
+ app = self.appList.Value
+ if not app:
+ dabo.ui.stop(_("Please select an application"))
+ return
+ # Add it to the MRUs
+ scheme, netloc, path, parameters, query, fragment =
urlparse.urlparse(self.Address)
+ stored = "%s://%s" % (scheme, netloc)
+ stamp = "%s" % int(round(time.time() * 100, 0))
+ prefMRU = self.PreferenceManager.mru
+ prefMRU.deleteByValue(stored)
+ prefMRU.setValue(stamp, stored)
+ self._runApp(app)
+
+
+
+## *!* ## Dabo Code ID: dButton-dPanel
+def onHit(self, evt):
+ self.Form.connectToServer()
Added: trunk/springboard/ui/springboard.cdxml
===================================================================
--- trunk/springboard/ui/springboard.cdxml (rev 0)
+++ trunk/springboard/ui/springboard.cdxml 2009-03-14 20:13:36 UTC (rev
5128)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<dForm code-ID="dForm-top" Name="dForm" Caption="Dabo Springboard"
SaveRestorePosition="False" Top="136" Height="381" Width="430"
designerClass="DesForm" Left="486">
+ <properties>
+ <Address>
+ <comment>The URL typed by the user</comment>
+ <defaultValue></defaultValue>
+ <deller>None</deller>
+ <getter>_getAddress</getter>
+ <propName>Address</propName>
+ <defaultType>string</defaultType>
+ <setter>None</setter>
+ </Address>
+ </properties>
+
+ <dSizer SlotCount="1" designerClass="LayoutSizer"
Orientation="Vertical">
+ <dPanel sizerInfo="{'HAlign': 'Left', 'VAlign': 'Top'}"
designerClass="controlMix" BackColor="lightSteelBlue">
+ <dSizer SlotCount="5" designerClass="LayoutSizer"
Orientation="Vertical">
+ <dPanel Spacing="40" sizerInfo="{'HAlign':
'Left', 'Border': 0}" designerClass="LayoutSpacerPanel"></dPanel>
+ <dBorderSizer SlotCount="2" Caption="Server
Address:" sizerInfo="{'BorderSides': ['Right', 'Left'], 'Proportion': 1,
'HAlign': 'Left', 'VAlign': 'Top', 'Border': 20, 'Expand': True}"
designerClass="LayoutBorderSizer" Orientation="Horizontal">
+ <dTextBox RegID="txtAddress"
Width="287" sizerInfo="{}" code-ID="dTextBox-dPanel"
designerClass="controlMix"></dTextBox>
+ <dButton code-ID="dButton-dPanel"
Width="76" sizerInfo="{'BorderSides': ['Left'], 'Border': 5}"
designerClass="controlMix" Caption="Connect"></dButton>
+ </dBorderSizer>
+ <dPanel Spacing="15" sizerInfo="{'HAlign':
'Left', 'Border': 0, 'Expand': True}"
designerClass="LayoutSpacerPanel"></dPanel>
+ <dBorderSizer SlotCount="1" Caption="Available
Applications:" sizerInfo="{'BorderSides': ['Right', 'Left'], 'Proportion': 2,
'HAlign': 'Left', 'VAlign': 'Top', 'Border': 20, 'Expand': True}"
designerClass="LayoutBorderSizer" Orientation="Horizontal">
+ <dListBox RegID="appList"
code-ID="dListBox-dPanel" sizerInfo="{'Proportion': 2}"
designerClass="controlMix" Choices="[]"></dListBox>
+ </dBorderSizer>
+ <dPanel sizerInfo="{'Proportion': 0, 'VAlign':
'Middle', 'Border': 8}" designerClass="controlMix" Name="dPanel1">
+ <dSizer SlotCount="3"
designerClass="LayoutSizer" Orientation="Horizontal">
+ <dPanel
sizerInfo="{'BorderSides': ['All'], 'HAlign': 'Left', 'VAlign': 'Top',
'Border': 0}" designerClass="LayoutPanel"></dPanel>
+ <dPanel
sizerInfo="{'BorderSides': ['All'], 'HAlign': 'Left', 'VAlign': 'Top',
'Border': 0}" designerClass="LayoutPanel"></dPanel>
+ <dButton
code-ID="dButton-dPanel-553" Width="99" sizerInfo="{'Border': 6}"
designerClass="controlMix" Caption="Launch App"></dButton>
+ </dSizer>
+ </dPanel>
+ </dSizer>
+ </dPanel>
+ </dSizer>
+</dForm>
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]