Querying now works, complete enough to write the UI
[jamaendo] / scripts / refresh_db
1 #!/usr/bin/env python
2 from jamaendo.api import refresh_dump
3 import locale, time
4
5 locale.setlocale(locale.LC_ALL, '')
6 code = locale.getpreferredencoding()
7
8 class Monitor(object):
9     def __init__(self):
10         self.done = False
11         self.last_percent = 0
12     def complete(self):
13         print "Done."
14         self.done = True
15     def progress(self, percent):
16         if percent - self.last_percent >= 5:
17             print "%d%%" % (percent)
18             self.last_percent = percent
19
20 def main():
21     print "Updating jamendo DB dump..."
22     monitor = Monitor()
23     refresh_dump(monitor.complete, monitor.progress, force=False)
24     while not monitor.done:
25         time.sleep(1)
26
27 if __name__ == "__main__":
28     main()