public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoostats:master commit in: server/, server/sql/
@ 2011-06-07 23:58 Vikraman Choudhury
  0 siblings, 0 replies; 2+ messages in thread
From: Vikraman Choudhury @ 2011-06-07 23:58 UTC (permalink / raw
  To: gentoo-commits

commit:     1b9697a090515d2a373e83b1094d6e08ec405c02
Author:     Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
AuthorDate: Tue Jun  7 23:58:01 2011 +0000
Commit:     Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
CommitDate: Tue Jun  7 23:58:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoostats.git;a=commit;h=1b9697a0

fixed sql bugs, POST success

---
 server/helpers.py   |   10 ++++++-
 server/post.py      |   16 +++++++----
 server/sql/init.sql |   73 ++++++++++++++++++++++++++-------------------------
 3 files changed, 56 insertions(+), 43 deletions(-)

diff --git a/server/helpers.py b/server/helpers.py
index 571ffa6..ad70e31 100644
--- a/server/helpers.py
+++ b/server/helpers.py
@@ -1,6 +1,14 @@
 
+import uuid
 import re
 
+# convert uuid string to raw bytes
+
+def uuidbin(string):
+  #TODO: string is not a valid uuid
+  u = uuid.UUID(string)
+  return u.bytes
+
 # split package name into cpv
 # based on pkgsplit code 
 # in portage/versions.py
@@ -11,7 +19,7 @@ def pkgsplit(pkgname):
   cpv['cat'] = pkgsplit[0]
   pv_re =re.compile(r'(?x)^(?P<pn>[\w\+][\w\+-]*?(?P<pn_inval>-(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)(-r(\d+))?)?)-(?P<ver>(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*))(-r(?P<rev>\d+))?$')
   m = pv_re.match(pkgsplit[1])
-  cpv['pkg'] = m.group('pkg')
+  cpv['pkg'] = m.group('pn')
   rev = m.group('rev')
   if rev is None:
  	cpv['ver'] = m.group('ver')

diff --git a/server/post.py b/server/post.py
index 1ca491d..b9f4deb 100644
--- a/server/post.py
+++ b/server/post.py
@@ -2,14 +2,16 @@
 
 from helpers import *
 
-def handler(uuid, data, db):
+def handler(uuid_str, data, db):
   #TODO: Handle exceptions
   if data['PROTOCOL'] != 1:
     return 'Unsupported protocol!'
 
-  if data['AUTH']['UUID'] != uuid:
+  if data['AUTH']['UUID'] != uuid_str:
     return 'Invalid uuid!'
 
+  uuid = uuidbin(uuid_str)
+
   # Insert in hosts
   db_host = db.select('hosts', vars={'uuid':uuid}, where='uuid=$uuid')
   if len(db_host):
@@ -20,9 +22,11 @@ def handler(uuid, data, db):
   db.insert('hosts', uuid=uuid, passwd=data['AUTH']['PASSWD'])
 
   # Insert in env
-  for var in ['ARCH','CHOST','CFLAGS','CXXFLAGS','FFLAGS','LDFLAGS','MAKEOPTS','SYNC','PLATFORM','PROFILE','LASTSYNC']:
-    db.insert('env', uuid=uuid, var=var, value=data[var])
-  
+  db.insert('env', uuid=uuid, arch=data['ARCH'], chost=data['CHOST'], cflags=data['CFLAGS'],
+	  cxxflags=data['CXXFLAGS'], fflags=data['FFLAGS'], ldflags=data['LDFLAGS'],
+	  makeopts=data['MAKEOPTS'], sync=data['SYNC'], platform=data['PLATFORM'],
+	  profile=data['PROFILE'], lastsync=data['LASTSYNC'])
+
   # Insert in global_keywords
   for keyword in data['ACCEPT_KEYWORDS']:
 	kwkey = get_kwkey(db, keyword)
@@ -74,4 +78,4 @@ def handler(uuid, data, db):
 	  ukey = get_ukey(db, useflag)
 	  db.insert('unset_useflags', ipkey=ipkey, ukey=ukey)
 
-  return 'POST for ' + uuid + ' successful'
+  return 'POST for ' + uuid_str + ' successful'

diff --git a/server/sql/init.sql b/server/sql/init.sql
index 72bf716..f177ee9 100644
--- a/server/sql/init.sql
+++ b/server/sql/init.sql
@@ -2,14 +2,31 @@
 -- run as 'gentoo'@'localhost' identified by 'gentoo'
 use `gentoostats`;
 
+drop table if exists `env`;
+drop table if exists `global_keywords`;
+drop table if exists `host_lang`;
+drop table if exists `host_features`;
+drop table if exists `host_mirrors`;
+drop table if exists `global_useflags`;
+drop table if exists `plus_useflags`;
+drop table if exists `minus_useflags`;
+drop table if exists `unset_useflags`;
+drop table if exists `installed_packages`;
+drop table if exists `lang`;
+drop table if exists `features`;
+drop table if exists `gentoo_mirrors`;
+drop table if exists `useflags`;
+drop table if exists `keywords`;
+drop table if exists `packages`;
+drop table if exists `repositories`;
 drop table if exists `hosts`;
+
 create table `hosts` (
   `uuid` binary (16),
   `passwd` varchar (32) not null,
   primary key (`uuid`)
-);
+) engine=innodb;
 
-drop table if exists `env`;
 create table `env` (
   `uuid` binary (16),
   `platform` varchar (128),
@@ -26,16 +43,14 @@ create table `env` (
   primary key (`uuid`),
   foreign key (`uuid`) references `hosts`(`uuid`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `keywords`;
 create table `keywords` (
   `kwkey` serial,
   `keyword` varchar (16),
   primary key (`keyword`)
-);
+) engine=innodb;
 
-drop table if exists `global_keywords`;
 create table `global_keywords` (
   `uuid` binary (16),
   `kwkey` bigint unsigned,
@@ -44,16 +59,14 @@ create table `global_keywords` (
   on delete cascade on update cascade,
   foreign key (`kwkey`) references `keywords`(`kwkey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `lang`;
 create table `lang` (
   `lkey` serial,
   `lang` varchar (16),
   primary key (`lang`)
-);
+) engine=innodb;
 
-drop table if exists `host_lang`;
 create table `host_lang` (
   `uuid` binary (16),
   `lkey` bigint unsigned,
@@ -62,16 +75,14 @@ create table `host_lang` (
   on delete cascade on update cascade,
   foreign key (`lkey`) references `lang`(`lkey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `features`;
 create table `features` (
   `fkey` serial,
   `feature` varchar (64),
   primary key (`feature`)
-);
+) engine=innodb;
 
-drop table if exists `host_features`;
 create table `host_features` (
   `uuid` binary (16),
   `fkey` bigint unsigned,
@@ -80,16 +91,14 @@ create table `host_features` (
   on delete cascade on update cascade,
   foreign key (`fkey`) references `features`(`fkey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `gentoo_mirrors`;
 create table `gentoo_mirrors` (
   `mkey` serial,
   `mirror` varchar (128),
   primary key (`mirror`)
-);
+) engine=innodb;
 
-drop table if exists `host_mirrors`;
 create table `host_mirrors` (
   `uuid` binary (16),
   `mkey` bigint unsigned,
@@ -98,25 +107,22 @@ create table `host_mirrors` (
   on delete cascade on update cascade,
   foreign key (`mkey`) references `gentoo_mirrors`(`mkey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `packages`;
 create table `packages` (
   `pkey` serial,
   `cat` varchar (32),
   `pkg` varchar (64),
   `ver` varchar (32),
   primary key (`cat`, `pkg`, `ver`)
-);
+) engine=innodb;
 
-drop table if exists `repositories`;
 create table `repositories` (
   `rkey` serial,
   `repo` varchar (32),
   primary key (`repo`)
-);
+) engine=innodb;
 
-drop table if exists `installed_packages`;
 create table `installed_packages` (
   `ipkey` serial,
   `uuid` binary (16),
@@ -124,7 +130,7 @@ create table `installed_packages` (
   `build_time` timestamp null default null,
   `counter` bigint unsigned,
   `kwkey` bigint unsigned,
-  `rkey` varchar (64),
+  `rkey` bigint unsigned,
   `size` bigint unsigned,
   primary key (`uuid`, `pkey`),
   foreign key (`uuid`) references `hosts`(`uuid`)
@@ -135,16 +141,14 @@ create table `installed_packages` (
   on delete cascade on update cascade,
   foreign key (`rkey`) references `repositories`(`rkey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `useflags`;
 create table `useflags` (
   `ukey` serial,
   `useflag` varchar (64),
   primary key (`useflag`)
-);
+) engine=innodb;
 
-drop table if exists `global_useflags`;
 create table `global_useflags` (
   `uuid` binary (16),
   `ukey` bigint unsigned,
@@ -153,9 +157,8 @@ create table `global_useflags` (
   on delete cascade on update cascade,
   foreign key (`ukey`) references `useflags`(`ukey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `plus_useflags`;
 create table `plus_useflags` (
   `ipkey` bigint unsigned,
   `ukey` bigint unsigned,
@@ -164,9 +167,8 @@ create table `plus_useflags` (
   on delete cascade on update cascade,
   foreign key (`ukey`) references `useflags`(`ukey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `minus_useflags`;
 create table `minus_useflags` (
   `ipkey` bigint unsigned,
   `ukey` bigint unsigned,
@@ -175,9 +177,8 @@ create table `minus_useflags` (
   on delete cascade on update cascade,
   foreign key (`ukey`) references `useflags`(`ukey`)
   on delete cascade on update cascade
-);
+) engine=innodb;
 
-drop table if exists `unset_useflags`;
 create table `unset_useflags` (
   `ipkey` bigint unsigned,
   `ukey` bigint unsigned,
@@ -186,4 +187,4 @@ create table `unset_useflags` (
   on delete cascade on update cascade,
   foreign key (`ukey`) references `useflags`(`ukey`)
   on delete cascade on update cascade
-);
+) engine=innodb;



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/gentoostats:master commit in: server/, server/sql/
@ 2011-06-15 20:55 Vikraman Choudhury
  0 siblings, 0 replies; 2+ messages in thread
From: Vikraman Choudhury @ 2011-06-15 20:55 UTC (permalink / raw
  To: gentoo-commits

commit:     d7090ff923b5cc1d6cab963b0f3431f64be31107
Author:     Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
AuthorDate: Wed Jun 15 20:55:16 2011 +0000
Commit:     Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
CommitDate: Wed Jun 15 20:55:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoostats.git;a=commit;h=d7090ff9

fix timestamps

---
 server/host.py      |    2 +-
 server/sql/init.sql |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/host.py b/server/host.py
index 50df581..f737a6d 100644
--- a/server/host.py
+++ b/server/host.py
@@ -117,7 +117,7 @@ class Host(object):
 	  rkey  = helpers.get_rkey(db, post_data_pkg['REPO'])
 
 	  # Insert in INSTALLED_PACKAGES
-	  ipkey = db.insert('INSTALLED_PACKAGES', UUID=uuid, PKEY=pkey, BUILD_TIME=post_data_pkg['BUILD_TIME'],
+	  ipkey = db.insert('INSTALLED_PACKAGES', UUID=uuid, PKEY=pkey, BUILD_TIME=int(post_data_pkg['BUILD_TIME']),
 	  	  COUNTER=post_data_pkg['COUNTER'], KWKEY=kwkey, RKEY=rkey, SIZE=post_data_pkg['SIZE'])
 
 	  # Insert in PLUS_USEFLAGS

diff --git a/server/sql/init.sql b/server/sql/init.sql
index 70b1ba7..5d7d6ab 100644
--- a/server/sql/init.sql
+++ b/server/sql/init.sql
@@ -37,7 +37,7 @@ create table `ENV` (
   `FFLAGS` varchar (64),
   `LDFLAGS` varchar (64),
   `MAKEOPTS` varchar (8),
-  `LASTSYNC` timestamp null default null,
+  `LASTSYNC` varchar(32),
   `PROFILE` varchar (64),
   `SYNC` varchar (128),
   primary key (`UUID`),
@@ -127,7 +127,7 @@ create table `INSTALLED_PACKAGES` (
   `IPKEY` serial,
   `UUID` binary (16),
   `PKEY` bigint unsigned,
-  `build_time` timestamp null default null,
+  `BUILD_TIME` bigint unsigned,
   `COUNTER` bigint unsigned,
   `KWKEY` bigint unsigned,
   `RKEY` bigint unsigned,



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-15 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-07 23:58 [gentoo-commits] proj/gentoostats:master commit in: server/, server/sql/ Vikraman Choudhury
  -- strict thread matches above, loose matches on Subject: below --
2011-06-15 20:55 Vikraman Choudhury

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox