[llvm-commits] [zorg] r125871 - in /zorg/trunk/llvmlab/llvmlab: data.py machine.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:41:11 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:41:11 2011
New Revision: 125871
URL: http://llvm.org/viewvc/llvm-project?rev=125871&view=rev
Log:
llvmlab: Sketch Machine objects.
Added:
zorg/trunk/llvmlab/llvmlab/machine.py
Modified:
zorg/trunk/llvmlab/llvmlab/data.py
Modified: zorg/trunk/llvmlab/llvmlab/data.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/data.py?rev=125871&r1=125870&r2=125871&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/data.py (original)
+++ zorg/trunk/llvmlab/llvmlab/data.py Fri Feb 18 10:41:11 2011
@@ -3,7 +3,7 @@
"""
from llvmlab import util
-from llvmlab import user
+from llvmlab import machine, user
class Data(util.simple_repr_mixin):
@staticmethod
@@ -14,18 +14,24 @@
users = [user.User.fromdata(u)
for u in data['users']]
- return Data(users)
+ machines = [machine.Machine.fromdata(u)
+ for u in data['machines']]
+ return Data(users, machines)
def todata(self):
return { 'version' : 0,
- 'users' : [u.todata()
- for u in self.users.values()
- if u is not self.admin_user] }
+ 'users' : [item.todata()
+ for item in self.users.values()
+ if item is not self.admin_user],
+ 'machine' : [item.todata()
+ for item in self.machines.values()] }
- def __init__(self, users):
- self.users = dict((u.id, u) for u in users)
+ def __init__(self, users, machines):
+ self.users = dict((item.id, item) for item in users)
self.admin_user = None
+ self.machines = dict((item.id, item) for item in machines)
+
def set_admin_user(self, user):
if user.id in self.users:
raise ValueError, "database contains admin user %r" % user.id
Added: zorg/trunk/llvmlab/llvmlab/machine.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/machine.py?rev=125871&view=auto
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/machine.py (added)
+++ zorg/trunk/llvmlab/llvmlab/machine.py Fri Feb 18 10:41:11 2011
@@ -0,0 +1,23 @@
+"""
+LLVM-Lab Machine Objects
+"""
+
+from llvmlab import util
+
+class Machine(util.simple_repr_mixin):
+ @staticmethod
+ def fromdata(data):
+ version = data['version']
+ if version != 0:
+ raise ValueError, "Unknown version"
+
+ return Machine(data['id'], data['hostname'])
+
+ def todata(self):
+ return { 'version' : 0,
+ 'id' : self.id,
+ 'hostname' : self.hostname }
+
+ def __init__(self, id, hostname):
+ self.id = id
+ self.hostname = hostname
More information about the llvm-commits
mailing list