~george-edison55/audataserver-proxy/trunk

« back to all changes in this revision

Viewing changes to audataserver-proxy

  • Committer: Nathan Osman
  • Date: 2011-11-08 17:57:49 UTC
  • Revision ID: admin@quickmediasolutions.com-20111108175749-gq11022ak5d73qgv
Added audatadump module from data dump package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
# Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
25
25
 
26
26
 
 
27
from audatadump   import get_most_recent_dump
27
28
from audataserver import threaded_aulibrary
28
29
from getopt       import getopt, GetoptError
29
30
from json         import dumps
46
47
 
47
48
class DataManager (cherrypy.process.plugins.SimplePlugin):
48
49
    
49
 
    # This is the packaged version of the data dump which
50
 
    # (depending on the update process) may or may not be
51
 
    # the most up to date package.
52
 
    packaged_data_dump_location   = '/usr/share/se-data-dumps'
53
 
    downloaded_data_dump_location = '/var/cache/se-data-dumps'
54
 
    
55
 
    # This is the name of the data dump index file
56
 
    data_dump_index_file = 'askubuntu.ddi'
57
 
    
58
 
    def get_most_recent_dump(self):
59
 
        packaged_dump_filename = path.join(self.packaged_data_dump_location,
60
 
                                           self.data_dump_index_file)
61
 
        downloaded_dump_filename = path.join(self.downloaded_data_dump_location,
62
 
                                             self.data_dump_index_file)
63
 
        if path.isfile(downloaded_dump_filename) and stat(downloaded_dump_filename).st_ctime > stat(packaged_dump_filename).st_ctime:
64
 
            return downloaded_dump_filename
65
 
        else:
66
 
            return packaged_dump_filename
67
 
    
68
50
    def start(self):
69
51
        cherrypy.log('\33[33mSpawning data manager thread...\33[m')
70
 
        self.data_manager = threaded_aulibrary(self.get_most_recent_dump())
 
52
        self.data_manager = threaded_aulibrary(get_most_recent_dump())
71
53
    
72
54
    def stop(self):
73
55
        cherrypy.log('\33[33mShutting down data manager thread...\33[m')