From ea526c8e236204f4eaccc76ce89019bdd0f7053f Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 12 Mar 2009 10:01:07 +0100 Subject: [PATCH] added server files, altered technical --- Makefile | 14 +++++++++ popcorn-client | 19 ++++++++++-- popcorn-server.c | 31 ++++++++++++++++++++ technical.txt | 89 ++++++++++++++++++++++++++------------------------------ 4 files changed, 104 insertions(+), 49 deletions(-) create mode 100644 Makefile create mode 100644 popcorn-server.c rewrite technical.txt (64%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5b804f5 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +CC = gcc +CFLAGS = -Wall +LDFLAGS = -lsqlite3 + +all: popcorn-server + +popcorn-server: popcorn-server.o + $(CC) $(LDFLAGS) $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -f *.o popcorn-server diff --git a/popcorn-client b/popcorn-client index 853bfd8..1ecab9b 100755 --- a/popcorn-client +++ b/popcorn-client @@ -28,10 +28,14 @@ import re import rpm import platform import httplib +import time package_name = 'popcorn-client' popcorn_server = 'stats.opensuse.org' +days_recent = 30 +days_unused = 30 + pathre = '^/(bin|boot|lib|lib64|opt/gnome/bin|opt/gnome/sbin|opt/kde3/bin|opt/kde3/sbin|sbin|usr/bin|usr/games|usr/include|usr/lib|usr/lib64|usr/libexec|usr/sbin|usr/share)/' class Statistics: @@ -48,6 +52,7 @@ class Statistics: def fill_packages(self): pathreprg = re.compile(pathre) + now = int(time.time()) ts = rpm.TransactionSet() mi = ts.dbMatch() for h in mi: @@ -63,13 +68,23 @@ class Statistics: accessed = atime except: pass - self.packages.append( (installed, accessed, name) ) + if accessed == 0: + cat = 'nof' # no-files + else: + if now - installed < 30 * 86400: + cat = 'rec' # recent + else: + if now - accessed < 30 * 86400: + cat = 'vot' # voted + else: + cat ='old' # old + self.packages.append( (cat, name) ) def serialize(self): ret = '' ret += 'START %s %s\n' % (self.package_ver, self.arch) for pkg in self.packages: - ret += '%s %s %s\n' % pkg + ret += '%s %s\n' % pkg ret += 'END\n' return ret diff --git a/popcorn-server.c b/popcorn-server.c new file mode 100644 index 0000000..df4ff0e --- /dev/null +++ b/popcorn-server.c @@ -0,0 +1,31 @@ +/* + Copyright (c) 2009 Pavol Rusnak + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include + +int main() +{ + return 0; +} diff --git a/technical.txt b/technical.txt dissimilarity index 64% index e5facb9..4cfebcd 100644 --- a/technical.txt +++ b/technical.txt @@ -1,47 +1,42 @@ -Submission format ------------------ - -START - -... -END - -where -- installed_time is when the package installed -- accessed_time is when the package was last used (any of its files touched) - (0 if none of the files from the package were used) -- submission date could be calculated as max(accessed_time) - -Watched files -------------- - -Only files in the following directories are watched: - -/bin -/boot -/lib -/lib64 -/opt/gnome/bin -/opt/gnome/sbin -/opt/kde3/bin -/opt/kde3/sbin -/sbin -/usr/bin -/usr/games -/usr/include -/usr/lib -/usr/lib64 -/usr/libexec -/usr/sbin -/usr/share - -Package categories ------------------- - -installed - package is in the list -voted - installed_time > 30 days, accessed_time < 30 days -old - installed_time > 30 days, accessed_time > 30 days -recent - installed_time < 30 days -no-files - accessed_time = 0 - -note: voted + old + recent + no-files = installed +Submission format +----------------- + +START + +... +END + + +Package categories +------------------ + +(nof) no-files - no watched file present in the package (see below) +(rec) recent - packages has been recently installed (less than 30 days) +(vot) voted - package is older than 30 days and has been used recently (less than 30 days) +(old) old - package is older than 30 days and hasn't been used recently + +note: nof + rec + vot + old = total number of installed packages + +Watched files +------------- + +To find out whether the package has been used recently, access times of the files +in the following directories are watched: + +/bin +/boot +/lib +/lib64 +/opt/gnome/bin +/opt/gnome/sbin +/opt/kde3/bin +/opt/kde3/sbin +/sbin +/usr/bin +/usr/games +/usr/include +/usr/lib +/usr/lib64 +/usr/libexec +/usr/sbin +/usr/share -- 2.11.4.GIT