#!/usr/bin/env python ## import os import cgi from igs.cgi import handler class UploadFile(handler.CGIPage): def body(self): form = cgi.FieldStorage() fname = form['file'].filename fin = form['file'].file foutname = os.path.join('/mnt', 'user_data', fname) fout = open(foutname, 'w') data = fin.read(1024) while data: fout.write(data) data = fin.read(1024) return foutname handler.generatePage(UploadFile())
#!/usr/bin/env python import cgi from igs.cgi.handler import CGIPage, generatePage class Page(CGIPage): def body(self): return '<html><head><title>testing</title></head><body>Hi</body></html>' generatePage(Page())
#!/usr/bin/env python ## import os import cgi from igs.cgi.handler import CGIPage, generatePage class Announce(CGIPage): def body(self): form = cgi.FieldStorage() open(os.path.join('/mnt', 'clovr', 'runtime', os.getenv('REMOTE_ADDR') + '-vappio.announce'), 'a').write(form['msg'].value + '\n') generatePage(Announce())
import cgi from igs.cgi.handler import CGIPage, generatePage from igs.utils import commands SGE_ROOTBIN = '/var/lib/gridengine/bin/lx26-ia64' class AddHost(CGIPage): def body(self): form = cgi.FieldStorage() host = form['host'].value sio = StringIO.StringIO() sgeRootBin = os.path.join(SGE_ROOTBIN) if 'ipaddr' in form and re.match('^\d+\.\d+\.\d+\.\d+$', form['ipaddr'].value): commands.runSystemEx('addEtcHosts.py %s %s' % (host, form['ipaddr'].value)) cmd = [ os.path.join(sgeRootBin, 'qconf'), '-ah', host, '&>', '/tmp/add_host.out' ] commands.runSystemEx(' '.join(cmd)) generatePage(AddHost())
from igs.cgi.handler import CGIPage, generatePage from igs.utils import commands SGE_ROOTBIN = '/var/lib/gridengine/bin/lx26-ia64' class AddHost(CGIPage): def body(self): form = cgi.FieldStorage() host = form['host'].value sio = StringIO.StringIO() sgeRootBin = os.path.join(SGE_ROOTBIN) if 'ipaddr' in form and re.match('^\d+\.\d+\.\d+\.\d+$', form['ipaddr'].value): commands.runSystemEx('addEtcHosts.py %s %s' % (host, form['ipaddr'].value)) cmd = [os.path.join(sgeRootBin, 'qconf'), '-ah', host, '&>', '/tmp/add_host.out'] commands.runSystemEx(' '.join(cmd)) generatePage(AddHost())
return False def getFType(path): if os.path.isdir(path): return 'dir' else: return 'file' class ListFiles(handler.CGIPage): def body(self): request = cgi_request.readQuery() if request['name'] == 'local': path = os.path.abspath(request['path']) if not pathValid(path): raise Exception('The path you provided is invalid') return dict([(f, dict(ftype=getFType(os.path.join(path, f)), name=f)) for f in os.listdir(path)]) else: # # Forward the request onto the appropriate machine cluster = cluster_ws.loadCluster('localhost', request['name']) request['name'] = 'local' return cgi_request.performQuery(cluster['master']['public_dns'], URL, request) handler.generatePage(ListFiles())
from igs.cgi import handler class UploadCred(handler.CGIPage): def body(self): form = cgi.FieldStorage() fname = form['file'].filename fin = form['file'].file md5 = hashlib.md5() data = fin.read(1024) fdata = '' while data: fdata += data md5.update(data) data = fin.read(1024) foutname = os.path.join('/mnt', 'keys', md5.hexdigest()) fout = open(foutname, 'w') fout.write(fdata) fout.close() return foutname handler.generatePage(UploadCred())
#!/usr/bin/env python ## import os import cgi from igs.cgi.handler import CGIPage, generatePage class Announce(CGIPage): def body(self): form = cgi.FieldStorage() open( os.path.join('/mnt', 'clovr', 'runtime', os.getenv('REMOTE_ADDR') + '-vappio.announce'), 'a').write(form['msg'].value + '\n') generatePage(Announce())