# Path: dIceCash.py
# PATH_DOWNLOAD_PRICE = "/files/download/price"
# 
# PATH_DOWNLOAD = "/files/download"
# 
# VERSION     = '2.0.081a'


import httplib, urllib
import my
import json
import os
from dIceCash import PATH_DOWNLOAD_PRICE, PATH_DOWNLOAD,VERSION
            data=json.loads(self.data)
            if len(data['sets'])==0:
                return False
            self.db._sets_upd('sets',str(data['id']))
            for k,v in data['sets'].items():
                if not self.db.sets.has_key(k):
                    self.db._sets_add('magazine',k,v)
                self.db._sets_upd(k,v)
            return True
        else:
            return False

    def download_file(self,ffrom,fto,fname):
        path=self.site+"/files/%s" % (fto+fname)
        if self.get('GET','/files/%s' % (ffrom+fname),{}):
            try:
                f=open(path,"wb")
                f.write(self.data)
                f.close()
            except:
                return False
            return True
        else:
            return False

    def download_upgrade_prog(self,fn):
        ffrom="download/upgrade/" 
        fto  ="download/" 
        path=self.site+"/files/%s" % (fto+fn)
        if self.download_file(ffrom,fto,fn):

# Path: dIceCash.py
# PATH_DOWNLOAD_PRICE = "/files/download/price"
# 
# PATH_DOWNLOAD = "/files/download"
# 
# VERSION     = '2.0.081a'


# Path: clientIceServ.py
import httplib, urllib
import my
import json
import os
from dIceCash import PATH_DOWNLOAD_PRICE, PATH_DOWNLOAD,VERSION

            data=json.loads(self.data)
            if len(data['sets'])==0:
                return False
            self.db._sets_upd('sets',str(data['id']))
            for k,v in data['sets'].items():
                if not self.db.sets.has_key(k):
                    self.db._sets_add('magazine',k,v)
                self.db._sets_upd(k,v)
            return True
        else:
            return False

    def download_file(self,ffrom,fto,fname):
        path=self.site+"/files/%s" % (fto+fname)
        if self.get('GET','/files/%s' % (ffrom+fname),{}):
            try:
                f=open(path,"wb")
                f.write(self.data)
                f.close()
            except:
                return False
            return True
        else:
            return False

    def download_upgrade_prog(self,fn):
        ffrom="download/upgrade/" 
        fto  ="download/" 
        path=self.site+"/files/%s" % (fto+fn)
        if self.download_file(ffrom,fto,fn):

            os.system("cd .. && mv dIceCash _dIceCash_%s && tar -xpjf _dIceCash_%s/%s" % (VERSION,VERSION,path))