fedora-hardware/hardware/hardware __init__.py, NONE, 1.1 controllers.py, NONE, 1.1 json.py, NONE, 1.1 model.py, NONE, 1.1 release.py, NONE, 1.1
Michael Patrick McGrath (mmcgrath)
fedora-extras-commits at redhat.com
Thu Jan 11 20:02:57 UTC 2007
- Previous message: fedora-hardware/hardware README.txt, NONE, 1.1 dev.cfg, NONE, 1.1 model_designer.tmp, NONE, 1.1 sample-prod.cfg, NONE, 1.1 setup.py, NONE, 1.1 setup.pyc, NONE, 1.1 start-hardware.py, NONE, 1.1
- Next message: fedora-hardware/hardware/hardware/static/css style.css,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: mmcgrath
Update of /cvs/fedora/fedora-hardware/hardware/hardware
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3389/hardware/hardware
Added Files:
__init__.py controllers.py json.py model.py release.py
Log Message:
added a ton of crap
--- NEW FILE __init__.py ---
--- NEW FILE controllers.py ---
from turbogears import controllers, expose
import sqlobject
from hardware import model
# import logging
# log = logging.getLogger("hardware.controllers")
from hardware.model import Host
from hardware.model import Device
from hardware.model import HostLinks
from sqlobject import SQLObjectNotFound
class statusBar:
def bar(num, tot):
for i in range (int( float(num) / tot * 50)):
print '|'
class Root(controllers.RootController):
@expose(template="hardware.templates.welcome")
def index(self):
import time
# log.debug("Happy TurboGears Controller Responding For Duty")
return dict(now=time.ctime())
@expose(template="hardware.templates.add")
def add(self, UUID, lsbRelease, OS, platform, bogomips, systemMemory, systemSwap, CPUVendor, numCPUs, CPUSpeed, language, defaultRunlevel, vendor, system):
import time
try:
hostSQL = Host.byUUID(UUID)
hostSQL.lsbRelease = lsbRelease
hostSQL.OS = OS
hostSQL.platform = platform
try:
hostSQL.bogomips = float(bogomips)
except:
hostSQL.bogomips = 0
hostSQL.systemMemory = int(systemMemory)
hostSQL.systemSwap = int(systemSwap)
hostSQL.CPUVendor = CPUVendor
hostSQL.numCPUs = int(numCPUs)
hostSQL.CPUSpeed = CPUSpeed
hostSQL.language = language
hostSQL.defaultRunlevel = int(defaultRunlevel)
hostSQL.vendor = vendor
hostSQL.system = system
except SQLObjectNotFound:
hostSQL = Host(UUID = UUID,
lsbRelease = lsbRelease,
OS = OS,
platform = platform,
bogomips = float(bogomips),
systemMemory = int(systemMemory),
systemSwap = int(systemSwap),
CPUVendor = CPUVendor,
numCPUs = int(numCPUs),
CPUSpeed = CPUSpeed,
language = language,
defaultRunlevel = int(defaultRunlevel),
vendor = vendor,
system = system)
return dict(hostObject=hostSQL)
@expose(template="hardware.templates.device")
def addDevice(self, UUID, Description, Bus, Driver, Class):
import time
from mx import DateTime
try:
deviceSQL = Device.byDescription(Description)
except SQLObjectNotFound:
deviceSQL = Device(Description = Description,
Bus = Bus,
Driver = Driver,
Class = Class,
DateAdded = DateTime.now())
link = HostLinks(hostUUID=UUID, deviceID=deviceSQL.id)
return dict(deviceObject=deviceSQL)
@expose(template="hardware.templates.raw")
def raw(self, UUID=None):
host = Host
hosts = host.select('1=1')
links = HostLinks
return dict(Hosts=hosts, Device=Device, HostLinks=HostLinks)
@expose(template="hardware.templates.stats")
def stats(self):
stats = {}
stats['archs'] = Host._connection.queryAll("Select platform, count(platform) as cnt from Host group by platform order by cnt desc")
stats['archstot'] = int(Host._connection.queryAll('select count(platform) from Host;')[0][0])
stats['OS'] = Host._connection.queryAll("Select o_s, count(o_s) as cnt from Host group by o_s order by cnt desc")
stats['runlevel'] = Host._connection.queryAll("Select default_runlevel, count(default_runlevel) as cnt from Host group by default_runlevel order by cnt desc")
stats['devices'] = Host._connection.queryAll("select Device.description, count(host_links.device_id) as cnt from host_links, Device where host_links.Device_id=Device.id group by host_links.device_id order by cnt desc limit 20;")
return dict(Host=Host, Device=Device, HostLinks=HostLinks, Stat=stats, statusBar=statusBar)
--- NEW FILE json.py ---
# A JSON-based API(view) for your app.
# Most rules would look like:
# @jsonify.when("isinstance(obj, YourClass)")
# def jsonify_yourclass(obj):
# return [obj.val1, obj.val2]
# @jsonify can convert your objects to following types:
# lists, dicts, numbers and strings
from turbojson.jsonify import jsonify
--- NEW FILE model.py ---
from sqlobject import *
from datetime import datetime
from turbogears.database import PackageHub
from turbogears.identity.soprovider import TG_User, TG_Group, TG_Permission
hub = PackageHub("hardware")
__connection__ = hub
class Device(SQLObject):
Description = StringCol(title="Device",alternateID=True)
Bus = StringCol(title="Bus")
Driver = StringCol(title="Module / Driver")
Class = StringCol()
DateAdded = DateTimeCol(title="Date Added")
class HostLinks(SQLObject):
hostUUID = ForeignKey("Host")
deviceID = IntCol(title="Device Link")
class Host(SQLObject):
UUID = StringCol(title="UUID",alternateID=True,unique=True,notNone=True)
lsbRelease = StringCol()
OS = StringCol()
platform = StringCol()
bogomips = FloatCol()
systemMemory = IntCol(title="System Memory")
systemSwap = IntCol(title="System Swap Memory")
vendor = StringCol(title="Machine Vendor")
system = StringCol(title="Machine Model")
CPUVendor = StringCol(title="CPU Vendor")
numCPUs = IntCol(title="Number of CPUs")
CPUSpeed = StringCol(title="CPU Speed")
language = StringCol(title="Language")
defaultRunlevel = IntCol(title="Default Runlevel")
--- NEW FILE release.py ---
# Release information about hardware
version = "1.0"
# description = "Your plan to rule the world"
# long_description = "More description about your plan"
# author = "Your Name Here"
# email = "YourEmail at YourDomain"
# copyright = "Vintage 2006 - a good year indeed"
# if it's open source, you might want to specify these
# url = "http://yourcool.site/"
# download_url = "http://yourcool.site/download"
# license = "MIT"
- Previous message: fedora-hardware/hardware README.txt, NONE, 1.1 dev.cfg, NONE, 1.1 model_designer.tmp, NONE, 1.1 sample-prod.cfg, NONE, 1.1 setup.py, NONE, 1.1 setup.pyc, NONE, 1.1 start-hardware.py, NONE, 1.1
- Next message: fedora-hardware/hardware/hardware/static/css style.css,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the scm-commits
mailing list