Livejournal
Log in
Post
Friends
My journal
thecolorblue
import pythong from allKnowledge
Jul 10, 2008 21:51
i'm learning python and i have to say i already like it way more than php. sure php has pear and you can get your module on that way, but python is just so elegant and simple -- like LISP, my first programming love (
Read more...
)
Leave a comment
Back to all threads
thecolorblue
July 12 2008, 20:48:43 UTC
here's my code. i think it's not working because the modules i'm working with are not respecting files. but i need to do some more digging.
from splunk import auth, search
import splunk.rest
import logging as logger
import time
import telnetlib
import base64
import cgi, os
import cgitb; cgitb.enable()
foo = '''
Inputs
'''
class inputs(splunk.rest.BaseRestHandler):
def handle_POST(self):
host="localhost"
tn = telnetlib.Telnet(host, 9999)
form = cgi.FieldStorage()
moo = form['foobar']
fileitem = form['splunkdata']
logger.debug(" -------- %s " % self.args['splunkdata'])
try:
tn.write(fileitem)
self.response.write("AWESOME!")
except Exception, e:
logger.exception(e)
self.response.write(e)
def handle_GET(self):
self.response.setHeader("content-type", "text/html")
self.response.write(foo)
Reply
kineticfactory
July 12 2008, 21:30:14 UTC
Try
tn.write(fileitem.read())
If it's likely to be big, you may want to put it in a loop and read it a chunk at a time.
Reply
Back to all threads
Leave a comment
Up
from splunk import auth, search
import splunk.rest
import logging as logger
import time
import telnetlib
import base64
import cgi, os
import cgitb; cgitb.enable()
foo = '''
Inputs
'''
class inputs(splunk.rest.BaseRestHandler):
def handle_POST(self):
host="localhost"
tn = telnetlib.Telnet(host, 9999)
form = cgi.FieldStorage()
moo = form['foobar']
fileitem = form['splunkdata']
logger.debug(" -------- %s " % self.args['splunkdata'])
try:
tn.write(fileitem)
self.response.write("AWESOME!")
except Exception, e:
logger.exception(e)
self.response.write(e)
def handle_GET(self):
self.response.setHeader("content-type", "text/html")
self.response.write(foo)
Reply
tn.write(fileitem.read())
If it's likely to be big, you may want to put it in a loop and read it a chunk at a time.
Reply
Leave a comment