Esempio n. 1
0
 def usage(self, aid, sid):
     WebClient.usage(self, aid, sid)
     print ""
     print "    ----Service specific commands-------"
     print ""
     print "    toggle_debug     appid  serviceid                                                      # enable/disable debug mode" 
     print "    on_autoscaling   appid  serviceid  adapt_interval  response_time_objective  strategy   #  enable autoscaling"
     print "    off_autoscaling  appid  serviceid                                                      #  disable autoscaling"
Esempio n. 2
0
    def main(self, argv):
        WebClient.main(self, argv)

        command = argv[1]

        if command == 'toggle_debug':
            try:
                sid = int(argv[2])
            except (IndexError, ValueError):
                self.usage(argv[0])
                sys.exit(0)

            self.toggle_debug(sid)
Esempio n. 3
0
File: php.py Progetto: dzeno/conpaas
    def main(self, argv):
        WebClient.main(self, argv)

        command = argv[1]

        if command == 'toggle_debug':
            try:
                sid = int(argv[2])
            except (IndexError, ValueError):
                self.usage(argv[0])
                sys.exit(0)

            self.toggle_debug(sid)
Esempio n. 4
0
 def __init__(self, webclient=None, url = None):
     self.urlobject = None
     self.webclient = webclient
     self.soupfragment = None
     if webclient is not None:
         self.soupfragment = BeautifulSoup(webclient.sourceCode())
     if url is not None:
         self.webclient = WebClient(url)
Esempio n. 5
0
    def main(self, argv):
        WebClient.main(self, argv)

        command = argv[1]

        if command in ['toggle_debug', 'on_autoscaling', 'off_autoscaling']:
            # second argument must be the service identifier
            try:
                sid = int(argv[2])
            except IndexError:
                print "Error: missing service identifier to command %s." % command
                sys.exit(1)
            except ValueError:
                print "Error: argument '%s' is not a service identifier." % argv[2]
                sys.exit(1)

        if command == 'toggle_debug':
            self.toggle_debug(sid)

        elif command == 'on_autoscaling':
            if len(argv) < 6:
                print "Error: missing arguments to command %s." % command
            try:
                cool_down = int(argv[3])
            except ValueError:
                print "Error: argument adapt_interval must be an integer (time in minutes)."
                sys.exit(1)
            try:
                response_time = int(argv[4])
            except ValueError:
                print "Error: argument response_time_objective must be an integer (time in milliseconds)."
                sys.exit(1)
            strategy = argv[5]
            if strategy not in AUTOSCALING_STRATEGIES:
                print "Error: argument strategy must be one of %s." % AUTOSCALING_STRATEGIES
                sys.exit(1)
            self.on_autoscaling(sid, cool_down, response_time, strategy)

        elif command == 'off_autoscaling':
            self.off_autoscaling(sid)

        else:
            print "Error: unknown sub-command '%s'." % command
Esempio n. 6
0
 def usage(self, cmdname):
     WebClient.usage(self, cmdname)
     print "    toggle_debug      serviceid           # enable/disable debug mode" 
     print "    on_autoscaling  serviceid  adapt_interval  response_time_objective  strategy   #  enable autoscaling"
     print "    off_autoscaling  serviceid             #  disable autoscaling"
Esempio n. 7
0
 def usage(self, cmdname):
     WebClient.usage(self, cmdname)
     print "    toggle_debug      serviceid           # enable/disable debug mode"
Esempio n. 8
0
File: php.py Progetto: dzeno/conpaas
 def usage(self, cmdname):
     WebClient.usage(self, cmdname)
     print "    toggle_debug      serviceid           # enable/disable debug mode" 
Esempio n. 9
0
class AsuntoFactory(object):

    @staticmethod
    def createFromURLObject(urlobject):
        factory = AsuntoFactory(url=urlobject.url)
        factory.urlobject = urlobject
        return factory

    def __init__(self, webclient=None, url = None):
        self.urlobject = None
        self.webclient = webclient
        self.soupfragment = None
        if webclient is not None:
            self.soupfragment = BeautifulSoup(webclient.sourceCode())
        if url is not None:
            self.webclient = WebClient(url)
            #self.soupfragment = BeautifulSoup(self.webclient.sourceCode())

    # Untested
    def _getfield_info(self, soupfragment):
        info = soupfragment.find("td", "subject windowbg2")
        if info is None:
            # It is a closed thread
            info = soupfragment.find("td", "subject lockedbg2")
        if info is None:
            print "Unkwon HTML for url: ", self.webclient
        return info

    def _get_answer_and_viewa_fragment(self, soupfragment):
        fragment = soupfragment.find('td', 'stats windowbg')
        if fragment is None:
            fragment = soupfragment.find('td', 'stats stickybg')
        if fragment is None:
            fragment = soupfragment.find('td', 'stats lockedbg')
        return fragment

    def create(self, soupfragment):
        result = dict()
        field = self._getfield_info(soupfragment)
        title = ""
        result["link"] = ""
        result["answers"] = ""
        result["views"] = ""
        result["location"] = ""
        if self.urlobject is not None:
            result["location"] = self.urlobject.description()

        #result['location'] = self.webclient.get_url_desc()
        if field is not None:
            title = UnicodeDammit(field.a.contents[0]).unicode_markup
            result["link"] = field.a['href']
            fragment = self._get_answer_and_viewa_fragment(soupfragment)
            if fragment is not None:
                result["answers"] = self._get_number_from(fragment.contents[0].strip())
                result["views"] = self._get_number_from(fragment.contents[2].strip())
            else:
                print "No answer and view bloq identified in thread: ", result["link"]
                result["answers"] = -1
                result["views"] = -1

        result["title"] = title.strip()

        #result['next_url'] = _nextUrl(soupfragment)
        return result

    def append_if_valid(self, l, msg):
        if len(msg['link']) > 0:
            l.append(msg)

    def createListOfAsuntos(self, soupFragment=None):
        if soupFragment is None:
            if self.soupfragment is None:
                self.soupfragment = BeautifulSoup(self.webclient.sourceCode())
            soupFragment = self.soupfragment
        result = list()
        for asunto in soupFragment.find("table", "table_grid").tbody.find_all("tr"):
            self.append_if_valid(result, self.create(asunto))
        return result

    def nextUrl(self):
        for link in self.soupfragment.find_all("a", "navPages"):
            content = str(link.contents[0])
            #print "Search: ", content
            if content == ">>":
                return link['href']
        return ""

    def changeUrl(self, url):
        self.webclient.load(url)
        self.soupfragment = BeautifulSoup(self.webclient.sourceCode())

    def _get_number_from(self, txt):
        return txt.split(' ')[0]