Skip to content

Commit

Permalink
TR13204/Infrastructure/python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
leemdi committed Apr 2, 2020
1 parent 64fc959 commit 843dacf
Show file tree
Hide file tree
Showing 7 changed files with 1,008 additions and 1,017 deletions.
9 changes: 4 additions & 5 deletions HttpRequestGovernor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Name: HttpRequestGovernor.py
# Purpose: provides a class for managing the frequency with which we can make HTTP requests,
# to ensure a configurable amount of "niceness" when reading from other sites
# Notes:
Expand All @@ -14,7 +13,7 @@
# You can also ask the governor to report on its statistics so far.

import time
import urllib2
import urllib.request, urllib.error, urllib.parse
import runCommand

# constants for convenience
Expand All @@ -31,7 +30,7 @@
def readURL (url):
# Purpose: given constraints on reading from https connections in python 2.7, we're just going
# to shell out and use curl for this
# Returns: string returned
# Returns: str.returned
# Throws: Exception if we have problems reading from 'url'

stdout, stderr, statusCode = runCommand.runCommand("curl '%s'" % url)
Expand Down Expand Up @@ -135,7 +134,7 @@ def get (self, url):

try:
response = readURL(url)
except Exception, e:
except Exception as e:
raise Exception('The server could not fulfill the request: %s' % str(e))
return response

Expand All @@ -150,4 +149,4 @@ def getStatistics (self):
'Average wait time: %6.3f sec' % (sum(self.timesWaited) / self.requestCount),
'Maximum wait time: %6.3f sec' % max(self.timesWaited),
]
return stats
return stats
5 changes: 2 additions & 3 deletions Install
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fi
#
# Compile all Python scripts.
#
python -c 'import compileall; compileall.compile_dir(".")'
${PYTHON} -m compileall -l -f .
if [ $? -ne 0 ]
then
echo "Error compiling Python source"
Expand All @@ -59,12 +59,11 @@ fi
# Set the proper permissions on the Python files.
#
chmod 775 *.py
chmod 664 *.pyc

#
# Copy the Python files to the given library directory.
#
for FILE in `ls *.py *.pyc`
for FILE in `ls *.py`
do
rm -f ${LIBRARY_DIRECTORY}/${FILE}
cp -p ${FILE} ${LIBRARY_DIRECTORY}
Expand Down
Loading

0 comments on commit 843dacf

Please sign in to comment.