def generate_all(): q=MyFile.all() mfiles=q.fetch(100) # delete all old files and data for mf in mfiles: bk=mf.blob_key blobstore.delete(bk) # delete data entity mf.delete() # dict of zipfiles being generated and their relevant generators generators={'openvpn.zip':generate_ovpn, 'windows.zip':generate_win, 'linux.zip':generate_linux, 'mac.zip':generate_mac, 'android.zip':generate_android } ip_data = fetch_ip_data() for fn,g in generators.iteritems(): data=g(ip_data) z=zipit(data) #compress the data blob_file=files.blobstore.create('application/zip', _blobinfo_uploaded_filename=fn) with files.open(blob_file,'a') as f: f.write(z) files.finalize(blob_file) blob_key = files.blobstore.get_blob_key(blob_file) mf=MyFile(name=fn,blob_key=str(blob_key)) mf.update_date=datetime.datetime.now().date() mf.put()
def generate_all(): q = MyFile.all() mfiles = q.fetch(100) # delete all old files and data for mf in mfiles: bk = mf.blob_key blobstore.delete(bk) # delete data entity mf.delete() # dict of zipfiles being generated and their relevant generators generators = { 'openvpn.zip': generate_ovpn, 'windows.zip': generate_win, 'linux.zip': generate_linux, 'mac.zip': generate_mac, 'android.zip': generate_android } ip_data = fetch_ip_data() for fn, g in generators.iteritems(): data = g(ip_data) z = zipit(data) #compress the data blob_file = files.blobstore.create('application/zip', _blobinfo_uploaded_filename=fn) with files.open(blob_file, 'a') as f: f.write(z) files.finalize(blob_file) blob_key = files.blobstore.get_blob_key(blob_file) mf = MyFile(name=fn, blob_key=str(blob_key)) mf.update_date = datetime.datetime.now().date() mf.put()
def get(self): q=MyFile.all() mfiles=q.fetch(100) template_values={'files':mfiles} content = template.render('templates/index.html',template_values) self.response.out.write(content)
def test_psco_concurrent(file_name): # Initialize file open(file_name, 'w').close() # Initialize PSCO object file_psco = MyFile(file_name) file_psco.makePersistent() # Launch NUM_TASKS CONCURRENT for i in range(NUM_TASKS): # Execute increment file_psco.write_three() # Synchronize file_psco = compss_wait_on(file_psco) total = file_psco.count_threes() print("Final counter value is " + str(total) + " three") file_psco.deletePersistent() # Re-create the file file2 = MyFile(file_name) open(file_name, 'a').close() # Launch NUM_TASKS INOUT for i in range(NUM_TASKS): # Execute increment file2.write_four() # Synchronize file2 = compss_wait_on(file2) total = file2.count_fours() print("Final counter value is " + str(total) + " fours")