a0eb070b36159223730af9309b35fbd3276733db max Wed Oct 2 02:15:53 2019 -0700 adding note about changed mysql library name, refs #24240 diff --git src/hg/pyLib/hgLib.py src/hg/pyLib/hgLib.py index 9edf74b..14bc174 100644 --- src/hg/pyLib/hgLib.py +++ src/hg/pyLib/hgLib.py @@ -8,42 +8,46 @@ # General rules for CGI in Python: # - never insert values into SQL queries. Write %s in the query and provide the # arguments to sqlQuery as a list. # - never print incoming HTTP argument as raw text. Run it through cgi.escape to # destroy javascript code in them. # Non-standard imports. They need to be installed on the machine. # We provide a pre-compiled library as part of our cgi-bin distribution as a # fallback in the "pyLib" directory. The idea of having pyLib be the last # directory in sys.path is that the system MySQLdb takes precedence. try: import MySQLdb except: print("Installation error - could not load MySQLdb for Python. Please tell your system administrator to run " \ - "one of these commands as root: 'yum install MySQL-python', 'apt-get install python-mysqldb' or 'pip install MySQL-python'.") + "one of these commands as root: 'yum install MySQL-python', 'apt-get install python-mysqldb' or 'pip install MySQL-python'. On a Python3 system, the command is usually 'sudo pip install mysqlclient'.") exit(0) # Imports from the Python 2.7 standard library # This is a CGI, not a WSGI - minimize global imports. Each library import can take up to 20msecs. import os, cgi, sys, logging, time from os.path import join, isfile, normpath, abspath, dirname, isdir, splitext from collections import namedtuple # start to support both python2 and python3 +try: from six.moves import http_cookies, urllib +except: + print("The python package 'six' could not be loaded. It is included with the Genome Browser. " + "Check if cgi-bin/pyLib/six.py is present and can be run from python.") # activate debugging output output only on dev import platform if "hgwdev" in platform.node(): import cgitb cgitb.enable() # debug level: a number. the higher, the more debug info is printed # to see most debug messages, set to 1 # another way to change this variable is by setting the URL variable "debug" to 1 verboseLevel = 0 cgiArgs = None # like in the kent tree, we keep track of whether we have already output the content-type line