Updated Slovenian translation
[banshee.git] / extras / metrics.py
blob0309e26fccd1610c9e2e5c8951cc88195663f233
1 #!/usr/bin/env python
3 import cgi
4 import os
6 # INITIAL SETUP:
7 # 1. mkdir data
8 # 2. chmod o-xr data
9 # 3. echo 0 > data/count
10 # 4. change data_dir below
11 data_dir = '/home/bansheeweb/download.banshee-project.org/metrics/data/';
13 uploaded = False
14 form = cgi.FieldStorage()
16 if form.file:
17 # Read the current count
18 f = open(data_dir + 'count', 'r')
19 count = f.read ()
20 count = int(count)
21 f.close ()
23 # Increment it and write it out
24 f = open(data_dir + 'count', 'w')
25 count = count + 1
26 f.write (str(count));
27 f.close ();
29 # Save the POSTed file
30 filename = data_dir + str(count) + '.json'
31 f = open(filename, 'w')
33 while 1:
34 line = form.file.readline()
35 if not line: break
36 f.write (line)
38 f.close ();
40 # gzip it
41 os.system ('gzip ' + filename)
42 uploaded = True
44 if uploaded:
45 print "Status-Code: 200"
46 print "Content-type: text/html"
47 print
48 else:
49 print "Status-Code: 500"