예제 #1
0
파일: command.py 프로젝트: jemmy655/TNT
    def _choose_instances(self):
        the_input = raw_input(
            "\t%s: choose from %s (space-delimited) or 'all' (blank line to cancel): "
            % (self.name, sorted(INSTANCES.keys()))).strip()
        # enable exit on blank line
        if the_input == '':
            return ['']

        return self._cleanse_input(the_input)
예제 #2
0
파일: command.py 프로젝트: jemmy655/TNT
    def run_for(self, the_input):
        names = self._cleanse_input(the_input)
        if len(names) == 0:
            self.run()

        if 'all' in names:
            names = INSTANCES.keys()

        self._run_for_all(self.sub_fn, names)
예제 #3
0
파일: command.py 프로젝트: jemmy655/TNT
    def _cleanse_input(self, the_input):
        names = the_input.strip().split(' ')
        # eliminate extra inner whitespace and filter out empty strings
        names = [name.strip() for name in names if name != '']
        # eliminate duplicate names
        names = set(names)
        # check for unknown instances
        for name in names:
            if name not in INSTANCES.keys() and name != 'all':
                print("\tno known instance called %s" % name)
                return []

        return names
예제 #4
0
파일: command.py 프로젝트: jemmy655/TNT
    def _choose_and_run(self, fn):
        while True:
            names = self._choose_instances()
            if '' in names:
                return

            to_return = False
            if 'all' in names:
                names = INSTANCES.keys()
                to_return = True

            self._run_for_all(fn, names)
            if to_return:
                return
예제 #5
0
def _start_node(instance):
    node0 = None
    if 'node-0' in INSTANCES.keys():
        node0 = INSTANCES['node-0']
    if instance.name != 'node-0' and node0 is not None and node0.node.descriptor != "":
        instance.start_node(node0.node.descriptor)
    elif instance.name == 'node-0' and node0 is not None and node0.node.descriptor == "":
        instance.start_node()
    else:
        print("FAILED TO START %s: did you forget about node-0?" %
              instance.name)
        print(
            "\t(if you are trying to start node-0, this means it may already be running)"
        )
예제 #6
0
def _print_info():
    for name in sorted(INSTANCES.keys()):
        instance = INSTANCES[name]
        # TODO this will wait forever (not blow up) if the instance is not running... check first!
        print("%s @ %s (%s)" % (name, instance.get_ip(), instance.instance_api.__class__))