Commit aa01db5b by Csók Tamás

Corrections based on merge request inputs

parent 951d822b
#!/usr/bin/env python
# -*- coding: utf-8 -*-
......@@ -6,10 +6,7 @@
import platform, logging, os, subprocess, webbrowser, sys
if sys.hexversion < 0x03000000 and sys.hexversion > 0x02000000:
import cPickle as pickle
import pickle
import cPickle as pickle
system = platform.system()
logger = logging.getLogger()
......@@ -43,32 +40,24 @@ def wall(text):
def accept():
import httplib
import urllib2, urllib
if not os.path.isfile("%s/%s" % (get_temp_dir(), file_name)):
logger.error("There isn't a request received currently")
done = False
# Load the saved url
url = pickle.load(open("%s/%s" % (get_temp_dir(), file_name), "rb"))
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
# Delete https:// or http:// from beginning
if url[:4].lower() == 'http':
url = url[url.find("/")+2:]
# Try to connect to the specified URL
conn = httplib.HTTPConnection(url[:url.find("/")])"Connection requested to %s" % url[:url.find("/")])
# Create the POST http request
conn.request("POST", url[url.find("/"):], "", headers)"Post reques sent to %s" % url)
# Fake data to post so we make urllib2 send a POST instead of a GET
# do POST request to
req = urllib2.Request(url, "")
rsp = urllib2.urlopen(req)
# Get the result of the request
response = conn.getresponse()
success = response.getheader('renewal')
if success is None:
success = ''
if success.lower() == 'success' or response.status == httplib.OK:
success =['renewal']
if success is not None or rsp.getcode() == 200:"Successfull renew, 200 - OK")
done = True
elif response.status == httplib.FOUND:
elif rsp.getcode() == 302:"Response is 302 - FOUND")
done = True
#!/usr/bin/env python
import notify
if __name__ == '__main__':
\ No newline at end of file
notify.wall("There was an unknown error while trying to renew this vm, please do it manually!")
Please register or sign in to reply
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment