Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-10-12 15:38:29 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-10-12 15:38:29 (GMT)
commitab7cd66374e8fb1b28a856d5ec314c3210aa14e8 (patch)
tree646741c4c7d703347aee269d8739bbbd44616a38 /shell
parentfb758f850675aa1c166a94a6c03b6683d2343925 (diff)
Add the olpc-register code
Diffstat (limited to 'shell')
-rw-r--r--shell/hardware/Makefile.am3
-rw-r--r--shell/hardware/schoolserver.py53
2 files changed, 55 insertions, 1 deletions
diff --git a/shell/hardware/Makefile.am b/shell/hardware/Makefile.am
index 320600e..8cd9c77 100644
--- a/shell/hardware/Makefile.am
+++ b/shell/hardware/Makefile.am
@@ -2,9 +2,10 @@ sugardir = $(pkgdatadir)/shell/hardware
sugar_PYTHON = \
__init__.py \
hardwaremanager.py \
+ keydialog.py \
nmclient.py \
nminfo.py \
- keydialog.py
+ schoolserver.py
dbusservicedir = $(sysconfdir)/dbus-1/system.d/
dbusservice_DATA = NetworkManagerInfo.conf
diff --git a/shell/hardware/schoolserver.py b/shell/hardware/schoolserver.py
new file mode 100644
index 0000000..cc92e02
--- /dev/null
+++ b/shell/hardware/schoolserver.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+from sugar import profile
+from xmlrpclib import ServerProxy, Error
+import sys
+import os
+
+REGISTER_URL = 'http://schoolserver:8080/'
+
+def register_laptop(url=REGISTER_URL):
+ if not have_ofw_tree():
+ return False
+
+ sn = read_ofw('mfg-data/SN')
+ uuid = read_ofw('mfg-data/U#')
+ sn = sn or 'SHF00000000'
+ uuid = uuid or '00000000-0000-0000-0000-000000000000'
+
+ nick = profile.get_nick_name()
+ pubkey = profile.get_pubkey()
+
+ try:
+ server = ServerProxy(url)
+ data = server.register(sn, nick, uuid, pubkey)
+ if data['success'] != 'OK':
+ print >> sys.stderr, "Error registering laptop: " + data['error']
+ return False
+ backupurl = data['backupurl']
+ jserver = data['jabberserver']
+ profile.set_server(jserver)
+ profile.set_trial2_backup(backupurl)
+ except Error, e:
+ print >> sys.stderr, "Error registering laptop: " + str(e)
+ return False
+
+ return True
+
+def have_ofw_tree():
+ return os.path.exists('/ofw')
+
+def read_ofw(path):
+ path = os.path.join('/ofw', path)
+ if not os.path.exists(path):
+ return None
+ fh = open(path, 'r')
+ data = fh.read().rstrip('\0\n')
+ fh.close()
+ return data
+
+if __name__ == "__main__":
+ url = REGISTER_URL
+ if len(sys.argv) > 1:
+ url = sys.argv[1]
+ register_laptop(url)