Commits

Arjan Scherpenisse committed 7617b01

Added mediamatic-specific network monitor, and made
network.NetworkWebMonitor's "url" argument required.

  • Participants
  • Parent commits 171ed21

Comments (0)

Files changed (6)

File doc/sparkd.1

 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.38.2.
-.TH SPARKD "1" "November 2010" "sparkd 0.9.2" "User Commands"
+.TH SPARKD "1" "December 2010" "sparkd 0.9.3" "User Commands"
 .SH NAME
 sparkd \- The Sparked application launcher
 .SH SYNOPSIS

File sparked/application.py

 The base application class.
 """
 
+import os
 import signal
 import time
 import inspect
     """
     base = options.get("id") or appName
     if kind == "temp":
-        return filepath.FilePath(options.get("temp-path") or "/tmp/" + base)
+        return filepath.FilePath(os.path.expanduser(options.get("temp-path") or "/tmp/" + base))
 
     if kind == "logfile":
         if options.get("logfile"):
-            return filepath.FilePath(options.get("logfile"))
+            return filepath.FilePath(os.path.expanduser(options.get("logfile")))
         if options.get("system-paths"):
             return filepath.FilePath("/var/log").child(base+".log")
         return getPath("temp", appName, options).child("sparkd.log")
 
     if kind == "pidfile":
         if options.get("pidfile"):
-            return filepath.FilePath(options.get("pidfile"))
+            return filepath.FilePath(os.path.expanduser(options.get("pidfile")))
         if options.get("system-paths"):
             return filepath.FilePath("/var/run").child(base+".pid")
         return getPath("temp", appName, options).child("sparkd.pid")
 
     if kind == "data":
         if options.get("data-path"):
-            return filepath.FilePath(options.get("data-path"))
+            return filepath.FilePath(os.path.expanduser(options.get("data-path")))
         if options.get("system-paths"):
             return filepath.FilePath("/usr/share").child(appName)
         return filepath.FilePath("data/")
 
     if kind == "db":
         if options.get("db-path"):
-            return filepath.FilePath(options.get("db-path"))
+            return filepath.FilePath(os.path.expanduser(options.get("db-path")))
         if options.get("system-paths"):
             return filepath.FilePath("/var/lib").child(base)
         return getPath("temp", appName, options).child("db")

File sparked/hardware/network.py

     Checks if the network connection is up by trying to reach a website.
     """
 
-    url = "http://www.google.com/"
+    url = None
     delay = 30
 
+    def __init__(self, url):
+        self.url = url
+
+
     def startService(self):
         self.connected = False
         self.loop()

File sparked/internet/mediamatic.py

     def added(self, container):
         self.container = container
 
+
+class MediamaticWebMonitor(monitors.NetworkWebMonitor):
+    title = "hwdeps.mediamatic.nl"
+
+    def __init__(self):
+        from socket import gethostname
+        monitors.NetworkWebMonitor.__init__(self, "http://hwdeps.mediamatic.nl/ping.php?host="+gethostname())

File sparked/monitors.py

 
 class NetworkWebMonitor(Monitor):
     title = "Internet connection"
+    url = None
+
+    def __init__(self, url="http://www.google.com/"):
+        self.url = url
+
 
     def added(self, container):
         self.container = container
-        self.svc = network.NetworkWebConnectionService()
+        self.svc = network.NetworkWebConnectionService(self.url)
         self.svc.setServiceParent(container)
         network.networkEvents.addObserver("web-connected", self.event)
 

File sparked/test/test_application.py

 Maintainer: Arjan Scherpenisse
 """
 import tempfile
+import os
 
 from twisted.trial import unittest
 from twisted.internet import task
 
 
     def testDataPath(self):
-        import os
         c = os.getcwd()
         self.assertEqual(c+"/data", getPath("data", "foo", {}).path)
         self.assertEqual(c+"/data", getPath("data", "foo", {'id': 'bar'}).path)
         self.assertEqual("/var/lib/bar", getPath("db", "foo", {'system-paths': True, 'id': 'bar'}).path)
 
 
+    def testPathExpansion(self):
+        self.assertEqual(os.getenv("HOME"), getPath("data", "foo", {"data-path": "~"}).path)
+        self.assertEqual(os.getenv("HOME")+"/tmp", getPath("data", "foo", {"data-path": "~/tmp"}).path)
+
+
 
 class TestApplicationOptions(unittest.TestCase):