if op == "remove":
hostname = raw_input("Please enter hostname to delete: ")
try:
- db.deletehost(hostname.decode("utf-8"))
+ db.deletehost(hostname)
except hostdb.NoSuchHost, e:
print "No such host '%s'" % e.name
sys.exit(1)
elif op == "modify":
hostname = raw_input("Please enter hostname to modify: ")
try:
- host = db.host(hostname.decode("utf-8"))
+ host = db.host(hostname)
except hostdb.NoSuchHost, e:
print "No such host '%s'" % e.name
sys.exit(1)
elif op == "add":
hostname = raw_input("Machine hostname: ")
try:
- db.host(hostname.decode("utf-8"))
+ db.host(hostname)
except hostdb.NoSuchHost, e:
pass
else:
line = raw_input("")
try:
- db.createhost(hostname.decode("utf-8"), platform.decode("utf-8"),
+ db.createhost(hostname, platform.decode("utf-8"),
owner.decode("utf-8"), owner_email.decode("utf-8"),
password.decode("utf-8"),
"".join(permission).decode("utf-8", "replace"))
elif op == "info":
hostname = raw_input("Hostname: ")
try:
- host = db.host(hostname.decode("utf-8"))
+ host = db.host(hostname)
except hostdb.NoSuchHost, e:
print "No such host '%s'" % e.name
sys.exit(1)
__storm_table__ = "build"
id = Int(primary=True)
- tree = Unicode()
+ tree = RawStr()
revision = RawStr()
- host = Unicode()
- compiler = Unicode()
+ host = RawStr()
+ compiler = RawStr()
checksum = RawStr()
age = Int()
- status_str = Unicode(name="status")
+ status_str = RawStr(name="status")
commit_revision = RawStr()
def status(self):
class StormHost(Host):
__storm_table__ = "host"
- name = Unicode(primary=True)
+ name = RawStr(primary=True)
owner_name = Unicode(name="owner")
owner_email = Unicode()
password = Unicode()
def createhost(self, name, platform=None, owner=None, owner_email=None,
password=None, permission=None):
"""See `HostDatabase.createhost`."""
- newhost = StormHost(unicode(name), owner=owner, owner_email=owner_email, password=password, permission=permission, platform=platform)
+ newhost = StormHost(name, owner=owner, owner_email=owner_email, password=password, permission=permission, platform=platform)
try:
self.store.add(newhost)
self.store.flush()
def get_previous_revision(self, tree, host, compiler, revision):
result = self.store.find(StormBuild,
- StormBuild.tree == unicode(tree),
- StormBuild.host == unicode(host),
- StormBuild.compiler == unicode(compiler),
+ StormBuild.tree == tree,
+ StormBuild.host == host,
+ StormBuild.compiler == compiler,
StormBuild.commit_revision == revision)
cur_build = result.any()
if cur_build is None:
raise NoSuchBuildError(tree, host, compiler, revision)
result = self.store.find(StormBuild,
- StormBuild.tree == unicode(tree),
- StormBuild.host == unicode(host),
- StormBuild.compiler == unicode(compiler),
+ StormBuild.tree == tree,
+ StormBuild.host == host,
+ StormBuild.compiler == compiler,
StormBuild.commit_revision != revision,
StormBuild.id < cur_build.id)
result = result.order_by(Desc(StormBuild.id))
def get_latest_revision(self, tree, host, compiler):
result = self.store.find(StormBuild,
- StormBuild.tree == unicode(tree),
- StormBuild.host == unicode(host),
- StormBuild.compiler == unicode(compiler))
+ StormBuild.tree == tree,
+ StormBuild.host == host,
+ StormBuild.compiler == compiler)
result = result.order_by(Desc(StormBuild.id))
build = result.first()
if build is None:
rev, timestamp = build.revision_details()
super(StormCachingBuildResultStore, self).upload_build(build)
new_basename = self.build_fname(build.tree, build.host, build.compiler, rev)
- new_build = StormBuild(new_basename, unicode(build.tree), unicode(build.host),
- unicode(build.compiler), rev)
+ new_build = StormBuild(new_basename, build.tree, build.host,
+ build.compiler, rev)
new_build.checksum = build.log_checksum()
new_build.age = build.age_mtime()
- new_build.status_str = unicode(build.status().__serialize__())
+ new_build.status_str = build.status().__serialize__()
self.store.add(new_build)
return new_build
class HostTests(testtools.TestCase):
def test_create_simple(self):
- host = hostdb.Host(name=u"foo")
+ host = hostdb.Host(name="foo")
self.assertEquals(None, host.owner)
self.assertEquals("foo", host.name)
def test_create_with_owner(self):
host = hostdb.Host(name="foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
self.assertEquals((u"Jelmer", u"jelmer@samba.org"), host.owner)
- self.assertEquals(u"foo", host.name)
+ self.assertEquals("foo", host.name)
class HostDatabaseTests(object):
def test_createhost(self):
- self.db.createhost(u"charis", u"linux", u"Jelmer", u"jelmer@samba.org", u"bla", u"Pemrission?")
+ self.db.createhost("charis", u"linux", u"Jelmer", u"jelmer@samba.org", u"bla", u"Pemrission?")
hosts = list(self.db.hosts())
self.assertEquals(1, len(hosts))
self.assertEquals("charis", hosts[0].name)
def test_create_already_exists(self):
- host = self.db.createhost(name=u"foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
- self.assertRaises(hostdb.HostAlreadyExists, self.db.createhost, name=u"foo",
+ host = self.db.createhost(name="foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
+ self.assertRaises(hostdb.HostAlreadyExists, self.db.createhost, name="foo",
owner=u"Jelmer", owner_email=u"jelmer@samba.org")
def test_delete(self):
- host = self.db.createhost(name=u"foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
- self.db.deletehost(u"foo")
+ host = self.db.createhost(name="foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
+ self.db.deletehost("foo")
def test_delete_doesntexist(self):
- self.assertRaises(hostdb.NoSuchHost, self.db.deletehost, u"foo")
+ self.assertRaises(hostdb.NoSuchHost, self.db.deletehost, "foo")
def test_update_platform(self):
- host = self.db.createhost(name=u"foo", owner=u"Jelmer",
+ host = self.db.createhost(name="foo", owner=u"Jelmer",
owner_email=u"jelmer@samba.org")
host.update_platform(u"Debian")
def test_update_owner(self):
- host = self.db.createhost(name=u"foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
+ host = self.db.createhost(name="foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
host.update_owner(new_owner=u"Matthieu", new_owner_email=u"mat@samba.org")
def test_create_hosts_list(self):
- self.db.createhost(name=u"foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org",
+ self.db.createhost(name="foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org",
platform=u"Debian")
- self.db.createhost(name=u"bla", owner=u"Jelmer", owner_email=u"jelmer@samba.org",
+ self.db.createhost(name="bla", owner=u"Jelmer", owner_email=u"jelmer@samba.org",
platform=u"Fedora")
expected = [
"foo: Debian\n",
self.assertEquals(expected, got)
def test_create_rsync_secrets(self):
- self.db.createhost(name=u"foo")
- self.db.createhost(name=u"bla", owner=u"Jelmer", owner_email=u"jelmer@samba.org",
+ self.db.createhost(name="foo")
+ self.db.createhost(name="bla", owner=u"Jelmer", owner_email=u"jelmer@samba.org",
platform=u"Fedora", password=u"o")
expected = [
"# rsyncd.secrets file\n",
for host in self.buildfarm.hostdb.hosts():
for compiler in self.buildfarm.compilers:
try:
- build = self.buildfarm.get_build(tree, host.name.encode("utf-8"), compiler)
+ build = self.buildfarm.get_build(tree, host.name, compiler)
status = build_status_html(myself, build)
except data.NoSuchBuildError:
pass
age_ctime,
host.platform.encode("utf-8"),
"<a href='%s?function=View+Host;host=%s;tree=%s;compiler=%s#%s'>%s</a>"
- % (myself, host.name.encode("utf-8"),
- tree, compiler, host.name.encode("utf-8"),
- host.name.encode("utf-8")),
+ % (myself, host.name,
+ tree, compiler, host.name,
+ host.name),
compiler, tree, status, build.status(),
revision_link(myself, revision, tree),
revision_time])
def _render_build_list_header(self, host):
yield "<div class='host summary'>"
yield "<a id='host' name='host'/>"
- yield "<h3>%s - %s</h3>" % (host.encode("utf-8"), self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
+ yield "<h3>%s - %s</h3>" % (host, self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
yield "<table class='real'>"
yield "<thead><tr><th>Target</th><th>Build<br/>Revision</th><th>Build<br />Age</th><th>Status<br />config/build<br />install/test</th><th>Warnings</th></tr></thead>"
yield "<tbody>"
"Tree", "Compiler", "Build Age", "Status", "Warnings")
for build in builds:
yield "%-12s %-10s %-10s %-10s %-10s\n" % (
- build.tree.encode("utf-8"), build.compiler.encode("utf-8"),
+ build.tree, build.compiler,
util.dhm_time(build.age_mtime()),
str(build.status()), build.err_count())
yield "\n"
self.buildfarm = buildfarm
# host.properties are unicode object and the framework expect string object
- self.hosts = dict([(host.name.encode("utf-8"), host) for host in self.buildfarm.hostdb.hosts()])
+ self.hosts = dict([(host.name, host) for host in self.buildfarm.hostdb.hosts()])
def main_menu(self):
"""main page"""