Skip to content

Commit

Permalink
Safe changes from xapi-project#20, Part 1: Update URLopener and xmlrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardkaindl committed Dec 2, 2023
1 parent 67a114b commit 918c313
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions XSConsoleMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import XenAPI
import urllib
import xml.dom.minidom

from XSConsoleAuth import *
from XSConsoleBases import *
from XSConsoleLang import *

try:
from urllib import URLopener
except ImportError:
from urllib.request import URLopener

class HotMetrics:
LIFETIME_SECS = 5 # The lifetime of objects in the cache before they are refetched
SNAPSHOT_SECS = 10 # The number of seconds of metric data to fetch
Expand Down Expand Up @@ -138,7 +141,7 @@ def FetchData(self):

httpRequest = 'http://localhost/rrd_updates?session_id=%s&start=%s&host=true' % (sessionID, int(time.time()) - self.SNAPSHOT_SECS)

socket = urllib.URLopener().open(httpRequest)
socket = URLopener().open(httpRequest)
try:
content = socket.read()
finally:
Expand Down
12 changes: 9 additions & 3 deletions XSConsoleRemoteTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import os, socket, xmlrpclib
import os, socket

from XSConsoleBases import *
from XSConsoleImporter import *
from XSConsoleLang import *
from XSConsoleLog import *
from XSConsoleLayout import *

import SocketServer
import SimpleXMLRPCServer
try:
import SimpleXMLRPCServer
import SocketServer
import xmlrpclib
except:
import socketserver as SocketServer
import xmlrpc.client as xmlrpclib
import xmlrpc.server as SimpleXMLRPCServer

class UnixSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
# Python 2.7's SimpleXMLRPCRequestHandler enables Nagle's algorithm by default
Expand Down

0 comments on commit 918c313

Please sign in to comment.