Пример #1
0
    def PostParseArgs(self):
        """Performs configuration based on parsed args"""
        loggingConfig = {}

        #Set up logging
        if not ourlogging.configured:
            #choose the correct level of logging
            if self.args['debug']:
                loggingConfig['debugInfo'] = True
                loggingConfig['consoleLevel'] = logging.DEBUG
            elif self.args['quiet'] == 1:
                loggingConfig['consoleLevel'] = logging.WARNING
            elif self.args['quiet'] == 2:
                loggingConfig['consoleLevel'] = logging.ERROR

            #set the log file
            loggingConfig['fileName'] = self.args['log-file']

            #call the logging config file with the arguments we've set up.
            ourlogging.config(**loggingConfig)

        #Setup our logger based off of the name of the command being run.
        self.logger = ourlogging.commandLogger(self.parser.prog)
        self.logger.debug("Logger created, starting logging now.")
Пример #2
0
    def PostParseArgs(self):
        """Performs configuration based on parsed args"""
        loggingConfig = {}

        #Set up logging
        if not ourlogging.configured:
            #choose the correct level of logging
            if self.args['debug']:
                loggingConfig['debugInfo'] = True
                loggingConfig['consoleLevel'] = logging.DEBUG  
            elif self.args['quiet'] == 1:
                loggingConfig['consoleLevel'] = logging.WARNING
            elif self.args['quiet'] == 2:
                loggingConfig['consoleLevel'] = logging.ERROR

            #set the log file
            loggingConfig['fileName'] = self.args['log-file']

            #call the logging config file with the arguments we've set up.
            ourlogging.config(**loggingConfig)

        #Setup our logger based off of the name of the command being run.
        self.logger = ourlogging.commandLogger(self.parser.prog)
        self.logger.debug("Logger created, starting logging now.")
Пример #3
0
import _winreg
import copy
import sys
import catalog
import cookielib
import platform
import ourlogging

#We emulate Mozilla Firefox on Windows 7 64 bit as our UA
red=urllib2.HTTPRedirectHandler()
userAgent=[('User-Agent',' Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0')]
cj = cookielib.CookieJar()
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),red)
opener.addheaders=userAgent

logger = ourlogging.config()


def getPage(url):
    """Returns the contents of a url as a string.

    This currently doesn't do anything to handle exceptions.

    @param url The url to grab a page from.
    @return A string containing the page contents of url.
    """
    try:
        opener.addheaders=userAgent + [('Referer', url)]
        f=opener.open(url)
        page = f.read()
        f.close()
Пример #4
0
import _winreg
import copy
import sys
import catalog
import cookielib
import platform
import ourlogging

#We emulate Mozilla Firefox on Windows 7 64 bit as our UA
red=urllib2.HTTPRedirectHandler()
userAgent=[('User-Agent',' Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0')]
cj = cookielib.CookieJar()
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),red)
opener.addheaders=userAgent

ourlogging.config()
logger = ourlogging.logger("utils")


def getPage(url):
    """Returns the contents of a url as a string.

    This currently doesn't do anything to handle exceptions.

    @param url The url to grab a page from.
    @return A string containing the page contents of url.
    """
    try:
        opener.addheaders=userAgent + [('Referer', url)]
        f=opener.open(url)
        page = f.read()
Пример #5
0
import catalog
import cookielib
import platform
import ourlogging

#We emulate Mozilla Firefox on Windows 7 64 bit as our UA
red = urllib2.HTTPRedirectHandler()
userAgent = [(
    'User-Agent',
    ' Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0'
)]
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), red)
opener.addheaders = userAgent

logger = ourlogging.config()


def getPage(url):
    """Returns the contents of a url as a string.

    This currently doesn't do anything to handle exceptions.

    @param url The url to grab a page from.
    @return A string containing the page contents of url.
    """
    try:
        opener.addheaders = userAgent + [('Referer', url)]
        f = opener.open(url)
        page = f.read()
        f.close()