From edce9b5c03374bb89ca31a2d77858586c32d7605 Mon Sep 17 00:00:00 2001 From: lxnay Date: Tue, 10 Mar 2009 21:57:14 +0000 Subject: [PATCH] Entropy/Services/UGC: - update structure of entropy_distribution_usage - other minor changes git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@3141 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/entropy/services/ugc/interfaces.py | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libraries/entropy/services/ugc/interfaces.py b/libraries/entropy/services/ugc/interfaces.py index 609be122e..5c6c18614 100644 --- a/libraries/entropy/services/ugc/interfaces.py +++ b/libraries/entropy/services/ugc/interfaces.py @@ -27,8 +27,8 @@ import subprocess import shutil from entropy.services.skel import RemoteDatabase from entropy.exceptions import * -from entropyConstants import etpConst, etpUi, etpCache, const_setup_perms, const_set_chmod, const_setup_file -from outputTools import brown, bold, blue +from entropy.const import etpConst, etpUi, etpCache, const_setup_perms, const_set_chmod, const_setup_file +from entropy.output import brown, bold, blue class Server(RemoteDatabase): @@ -117,6 +117,8 @@ class Server(RemoteDatabase): `ts` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `ip_address` VARCHAR( 15 ), `entropy_ip_locations_id` INT UNSIGNED NULL DEFAULT 0, + `creation_date` DATETIME DEFAULT NULL, + `hits` INT UNSIGNED NULL DEFAULT 0, FOREIGN KEY (`entropy_branches_id`) REFERENCES `entropy_branches` (`entropy_branches_id`), FOREIGN KEY (`entropy_release_strings_id`) REFERENCES `entropy_release_strings` (`entropy_release_strings_id`), KEY `ip_address` (`ip_address`), @@ -162,7 +164,8 @@ class Server(RemoteDatabase): dev-python/gdata ''' def __init__(self, connection_data, store_path, store_url = ''): - import entropyTools, dumpTools + import entropy.dump as dumpTools + import entropy.tools as entropyTools from entropy.misc import EntropyGeoIP self.EntropyGeoIP = EntropyGeoIP self.entropyTools, self.dumpTools = entropyTools, dumpTools @@ -1184,19 +1187,23 @@ class Server(RemoteDatabase): entropy_distribution_usage_id = self.is_user_ip_available_in_entropy_distribution_usage(ip_addr) if entropy_distribution_usage_id == -1: entropy_ip_locations_id = self.handle_entropy_ip_locations_id(ip_addr) - self.execute_query('INSERT INTO entropy_distribution_usage VALUES (%s,%s,%s,%s,%s,%s)',( + self.execute_query('INSERT INTO entropy_distribution_usage VALUES (%s,%s,%s,%s,%s,%s,%s,%s)',( None, branch_id, rel_strings_id, None, ip_addr, entropy_ip_locations_id, + self.get_date(), + 1, ) ) else: self.execute_query(""" UPDATE entropy_distribution_usage SET `entropy_branches_id` = %s, - `entropy_release_strings_id` = %s WHERE `entropy_distribution_usage_id` = %s + `entropy_release_strings_id` = %s, + `hits` = `hits`+1, + WHERE `entropy_distribution_usage_id` = %s """,( branch_id, rel_strings_id, @@ -1207,8 +1214,6 @@ class Server(RemoteDatabase): if do_commit: self.commit() return True - pass - def is_user_ip_available_in_entropy_distribution_usage(self, ip_address): self.check_connection() self.execute_query('SELECT entropy_distribution_usage_id FROM entropy_distribution_usage WHERE `ip_address` = %s',(ip_address,)) @@ -1519,8 +1524,8 @@ class Server(RemoteDatabase): class Client: import socket - import dumpTools - import entropyTools + import entropy.dump as dumpTools + import entropy.tools as entropyTools import zlib import select def __init__(self, OutputInterface, ClientCommandsClass, quiet = False, show_progress = True, output_header = '', ssl = False, socket_timeout = 25):