def clear_info(info_type=None): """ clear startup info and force a new version parameter: info_type = 'user' or 'common' or 'all' """ if not info_type: info_type = webnotes.form_dict.get('info_type') from build.version import VersionControl vc = VersionControl() flist = [] if info_type=='common': flist = ['index.cgi?cmd=webnotes.startup.common_info'] elif info_type=='user': flist = [f[0] for f in vc.repo.sql("""select fname from files where fname like ?""",\ ('index.cgi?cmd=webnotes.startup.user_info%',))] elif info_type=='all': flist = [f[0] for f in vc.repo.sql("""select fname from files where fname like ?""",\ ('index.cgi?cmd=webnotes.startup%',))] else: webnotes.msgprint("info_type not found: %s" % info_type) for f in flist: print 'clearing %s' % f vc.remove(f) vc.commit() vc.close()
def get_info(fname, key): """ get info from version or re-build """ from build.version import VersionControl vc = VersionControl() # from versions (same static) if vc.exists(fname): content = vc.get_file(fname)['content'] else: content = globals().get('get_content_'+key)() import json content = json.dumps(content) # add in vcs vc.add(fname=fname, content=content) vc.commit() vc.close() webnotes.response['content'] = content return