Get status from APC NIS and print output on stdout.
766279
def main():
    """"""
    # No need to use "proper" names on such simple code.
    # pylint: disable=invalid-name
    p = argparse.ArgumentParser()
    p.add_argument("--host", default="localhost")
    p.add_argument("--port", type=int, default=3551)
    p.add_argument("--strip-units", action="store_true", default=False)
    args = p.parse_args()
    status.print_status(
        status.get(args.host, args.port),
        strip_units=args.strip_units
    )
843236
def idle_print_status(self):
        ''''''
        now = time.time()
        if (now - self.last_idle_status_printed_time) >= 10:
            print (self.status())
            self.last_idle_status_printed_time = now
            self.prev_download = self.download
976828
def status(self):
        """"""
        my_name = os.path.basename(sys.argv[0])
        if self._already_running():
            message = "{0} (pid  {1}) is running...\n".format(my_name, self.pid)
            sys.stdout.write(message)
            return 0
        sys.stdout.write("{0} is stopped\n".format(my_name))
        return 3
1313587
def show_status(self):
        
        txt = 'Agent Status:\n'
        print(txt)
        txt += "start_x  = " + str(self.start_x) + "\n"
        txt += "start_y  = " + str(self.start_y) + "\n"
        txt += "target_x = " + str(self.target_x) + "\n"
        txt += "target_y = " + str(self.target_y) + "\n"
        txt += "current_x = " + str(self.current_x) + "\n"
        txt += "current_y = " + str(self.current_y) + "\n"
       
        
        print(self.grd)
        return txt
676449
def get_status(
        status):
    
    if status == SUCCESS:
        return 'SUCCESS'
    elif status == FAILED:
        return 'FAILED'
    elif status == ERR:
        return 'ERR'
    elif status == EX:
        return 'EX'
    elif status == NOT_RUN:
        return 'NOT_RUN'
    elif status == INVALID:
        return 'INVALID'
    elif status == NOT_DONE:
        return 'NOT_DONE'
    else:
        return 'unsupported status={}'.format(
            status)
313694
def check_output(cmd):
    """"""
    popen = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    out = popen.communicate()[0].strip()
    if not isinstance(out, str):
        out = out.decode(sys.stdout.encoding)
    return out
679359
def _status_apf():
    '''
    
    '''
    status = 0
    table = iptc.Table(iptc.Table.FILTER)
    for chain in table.chains:
        if 'sanity' in chain.name.lower():
            status = 1
    return True if status else False
547096
def status(queue, munin, munin_config):
    """"""
    if munin_config:
        return status_print_config(queue)
    queues = get_queues(queue)
    for queue in queues:
        status_print_queue(queue, munin=munin)
    if not munin:
        print('-' * 40)
786433
def status(self):
        ''''''
        message = self.status_message
        if message is None:
            message = STATUS[self.status_code]
        return '%s %s' % (self.status_code, message)
1374012
def _print_status(self):
        ''''''
        self._clear_line()

        self._print('  ')

        if self.max_value:
            self._print_percent()
            self._print(' ')
            self._print_bar()
        else:
            self._print_throbber()

        self._print(' ')

        if self.measurement == Measurement.bytes:
            self._print_size_downloaded()
        else:
            self._print(self.current_value)

        self._print(' ')
        self._print_duration()
        self._print(' ')

        if self.measurement == Measurement.bytes:
            self._print_speed()

        self._flush()
133659
def _parse_status(self, output):
        '''
        
        '''
        parsed = self._parse_machine_readable_output(output)
        statuses = []
        # group tuples by target name
        # assuming tuples are sorted by target name, this should group all
        # the tuples with info for each target.
        for target, tuples in itertools.groupby(parsed, lambda tup: tup[1]):
            # transform tuples into a dict mapping "type" to "data"
            info = {kind: data for timestamp, _, kind, data in tuples}
            status = Status(name=target, state=info.get('state'),
                            provider=info.get('provider-name'))
            statuses.append(status)

        return statuses
1010425
def on_status(self, status):
        """"""
        self.out.write(json.dumps(status))
        self.out.write(os.linesep)

        self.received += 1
        return not self.terminate
778705
def _grep_status(self, status_type):
        
        args = "qstat -f {}".format(self.id).split()
        res, _ = call(args)
        exit_status = [line for line in res.split('\n')
                if 'exit_status' in line]
        try:
            _, __, code = exit_status[0].split()
        except IndexError:
            code = None

        if status_type == 'complete' and code == '0':
            return True
        elif status_type == 'error' and code != '0':
            return True
        else:
            return False
1236356
def display_status(self, fmtstr, itst):
        

        if self.opt['Verbose']:
            hdrtxt = type(self).hdrtxt()
            hdrval = type(self).hdrval()
            itdsp = tuple([getattr(itst, hdrval[col]) for col in hdrtxt])
            if not self.opt['AutoRho', 'Enabled']:
                itdsp = itdsp[0:-1]

            print(fmtstr % itdsp)
1344144
def _check_status(self, ibsta):
        """"""
        if ibsta & 0x4000:
            raise LinuxGpib.Timeout()
        elif ibsta & 0x8000:
            raise LinuxGpib.Error(self.error_status)
810837
def idle_print_status(self):
        ''''''
        now = time.time()
        if (now - self.last_idle_status_printed_time) >= 10:
            print(self.status())
            self.last_idle_status_printed_time = now
79975
def basic_status_and_output(messages)
      status =
        if messages.any? { |message| message.type == :error }
          :fail
        elsif messages.any? { |message| message.type == :warning }
          :warn
        else
          :pass
        end

      output = ''
      if messages.any?
        output += messages.join("\n") + "\n"
      end

      [status, output]
    end