Print any command sent in raw format
347633
def _raw(self, msg):
        
        if len(msg) != self.device.write(self.out_ep, msg, self.interface):
            self.device.write(self.out_ep, self.errorText, self.interface)
            raise TicketNotPrinted()
927778
def __printCommandSyntax(self, command):
        
        commandHelp = self.completion[command]
        if commandHelp != None and len(commandHelp) > 2:
            commandValues = commandHelp[2]
            #commandDefault = commandHelp[3]
            displayHelp = [self._color(self.COLOR_WHITE, command)]
            if commandValues != None:
                valuesIsEnum = len(commandHelp) >= 6
                if '+' in command or command.upper() in ['ATS0']:
                    displayHelp.append(self._color(self.COLOR_WHITE, '='))
                displayHelp.append(('|' if valuesIsEnum else ',').join([value[0] for value in commandValues]))
            sys.stdout.write('\r Syntax: {0}\n'.format(self._color(self.COLOR_WHITE, ''.join(displayHelp))))
            sys.stdout.flush()
            self._refreshInputPrompt(len(self.inputBuffer))
916685
def _print mode, text, opts, caler, bind, cfg
      log_ = opts&NOLOG==0
      print_ = opts&NOPRINT==0
      str = cfg.fmt.dup
      str.gsub! "%mode", @highlight[mode]
      if bind
        text = bind.report text
      elsif !text.is String
        text = text.inspect
      elsif cfg.detect_comments and text =~ /\A[ \t]*#[ \t]+\S/
        text = "\n" + @c.green(text.gsub(/^([ \t]*#[ \t])?/, cfg.precede_comments).chop)
      end
      out = cfg.out
      if cfg._time or cfg.path_format
        now = Time.now
        if cfg._time
          time = now.strftime cfg.tf[0]
          time << ".#{cfg.tf[1]%[now.usec/1000]}" if cfg.tf[1]
          str.gsub! "%time", time
        end
        out = now.strftime cfg.out if cfg.path_format
      end
      if caler
        caler.sub!(/block (?:\((\d+) levels\) )?in/) {"{#{$1||1}}"}
        str.gsub! "%caller", caler.sub(String::SIMPLE_CALLER_RE, cfg.cf)
      end
      str.gsub! "%text", text
      str << "\n" if opts&INLINE==0
      log_str = cfg.color_out ? str : @c.clean(str)
      RMTools.write out, log_str if log_
      Kernel::print str if print_
    end
905882
def _run(method, cmd, cwd=None, shell=True, universal_newlines=True,
             stderr=STDOUT):
        """"""
        if not cmd:
            error_msg = 'Passed empty text or list'
            raise AttributeError(error_msg)
        if isinstance(cmd, six.string_types):
            cmd = str(cmd)
        if shell:
            if isinstance(cmd, list):
                cmd = ' '.join(cmd)
        else:
            if isinstance(cmd, str):
                cmd = cmd.strip().split()
        out = method(cmd, shell=shell, cwd=cwd, stderr=stderr,
                     universal_newlines=universal_newlines)
        if isinstance(out, bytes):
            out = out.decode('utf-8')
        return str(out).strip()
1192833
def raw_command(self, lun, netfn, raw_bytes):
        
        return self.interface.send_and_receive_raw(self.target, lun, netfn,
                                                   raw_bytes)
655891
def line_print(self):
        
        inv_types = {v: k for k, v in defines.Types.items()}

        if self._code is None:
            self._code = defines.Codes.EMPTY.number

        msg = "From {source}, To {destination}, {type}-{mid}, {code}-{token}, ["\
            .format(source=self._source, destination=self._destination, type=inv_types[self._type], mid=self._mid,
                    code=defines.Codes.LIST[self._code].name, token=self._token)
        for opt in self._options:
            msg += "{name}: {value}, ".format(name=opt.name, value=opt.value)
        msg += "]"
        if self.payload is not None:
            if isinstance(self.payload, dict):
                tmp = list(self.payload.values())[0][0:20]
            else:
                tmp = self.payload[0:20]
            msg += " {payload}...{length} bytes".format(payload=tmp, length=len(self.payload))
        else:
            msg += " No payload"
        return msg
440281
def handle_raw_packet(self, raw_packet):
        """"""
        log.debug('got packet: %s', raw_packet)
        if rflink_log:
            print(raw_packet, file=rflink_log)
            rflink_log.flush()
        packet = None
        try:
            packet = decode_packet(raw_packet)
        except:
            log.exception('failed to parse packet: %s', packet)

        log.debug('decoded packet: %s', packet)

        if packet:
            if 'ok' in packet:
                # handle response packets internally
                log.debug('command response: %s', packet)
                self._last_ack = packet
                self._command_ack.set()
            else:
                self.handle_packet(packet)
        else:
            log.warning('no valid packet')
180836
def pylint_raw(options):
    
    command = ['pylint']
    command.extend(options)

    proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    outs, __ = proc.communicate()

    return outs.decode()
1212437
def _format_args():
        """"""
        if request and request.args.get('prettyprint'):
            return dict(
                indent=2,
                separators=(', ', ': '),
            )
        else:
            return dict(
                indent=None,
                separators=(',', ':'),
            )
1366358
def call(commands, *, print_result=False, raise_exception=False,
         print_commands=False):
    
    if isinstance(commands, str):
        commands = commands.split()

    if not (isinstance(commands, tuple) or
            isinstance(commands, list)):
        raise ValueError("Function 'call' does not accept a 'commands'"
                         "argument of type '{}'".format(type(commands)))

    if raise_exception:
        print_result = False
    try:
        process = subprocess.Popen(commands,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        if print_commands:
            _print_commands(commands)

    except:
        # TODO Why couldn't we just do 'except Exception as output'
        output = traceback.format_exc()
        result = Result(1, stderr=output)
        if print_result and not raise_exception:
            print(output, file=sys.stderr)

    else:
        result = _extract_output(process, print_result, raise_exception)

    if raise_exception and (result.returncode == 1):
        message = "An error occurred in an external process:\n\n{}"
        raise Exception(message.format(result.getStderr()))
    return result
1008646
def cmd(str, print_ret=False, usr_pwd=None, run=True):
	
	if usr_pwd:
		str = 'echo {} | sudo -u {} {} '.format(usr_pwd[1], usr_pwd[0], str)

	print('  [>] {}'.format(str))

	if run:
		err, ret = commands.getstatusoutput(str)
	else:
		err = None
		ret = None

	if err:
		print('  [x] {}'.format(ret))
		raise Exception(ret)
	if ret and print_ret:
		lines = ret.split('\n')
		for line in lines:
			print('  [<] {}'.format(line))
	return ret
731284
def raw(self, query, settings=None, stream=False):
        '''
        
        '''
        query = self._substitute(query, None)
        return self._send(query, settings=settings, stream=stream).text
275420
def format_for_exception
      return "Command execution failed. STDOUT/STDERR suppressed for sensitive resource" if sensitive
      msg = ""
      msg << "#{@terminate_reason}\n" if @terminate_reason
      msg << "---- Begin output of #{command} ----\n"
      msg << "STDOUT: #{stdout.strip}\n"
      msg << "STDERR: #{stderr.strip}\n"
      msg << "---- End output of #{command} ----\n"
      msg << "Ran #{command} returned #{status.exitstatus}" if status
      msg
    end
878848
def send_command(self, cmd, params=None, raw=False):
        '''
        
        '''
        paramstr = ''
        if params:
            paramstr = urlencode(params)
            paramstr = '&' + paramstr if paramstr else ''
        cmdurl = 'http://%s/cgi-bin/CGIProxy.fcgi?usr=%s&pwd=%s&cmd=%s%s' % (
                                                                  self.url,
                                                                  self.usr,
                                                                  self.pwd,
                                                                  cmd,
                                                                  paramstr,
                                                                  )
        if self.ssl and ssl_enabled:
            cmdurl = cmdurl.replace('http:','https:')

        # Parse parameters from response string.
        if self.verbose:
            print ('Send Foscam command: %s' % cmdurl)
        try:
            raw_string = ''
            if self.ssl and ssl_enabled:
                gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)  # disable cert
                raw_string = urlopen(cmdurl,context=gcontext, timeout=5).read()
            else:
                raw_string = urlopen(cmdurl,timeout=5).read()
            if raw:
                if self.verbose:
                    print ('Returning raw Foscam response: len=%d' % len(raw_string))
                return FOSCAM_SUCCESS, raw_string
            root = ET.fromstring(raw_string)
        except:
            if self.verbose:
                print ('Foscam exception: ' + raw_string)
            return ERROR_FOSCAM_UNAVAILABLE, None
        code = ERROR_FOSCAM_UNKNOWN
        params = OrderedDict()
        for child in root.iter():
            if child.tag == 'result':
                code = int(child.text)

            elif child.tag != 'CGI_Result':
                params[child.tag] = unquote(child.text)

        if self.verbose:
            print ('Received Foscam response: %s, %s' % (code, params))
        return code, params
409416
def pretty_print_str(self):
        '''
        
        '''
        retval = ''
        # dfs
        todo = [self.root]
        while todo:
            current = todo.pop()
            for char in reversed(sorted(current.keys())):
                todo.append(current[char])
            indent = ' ' * (current.depth * 2)
            retval += indent + current.__unicode__() + '\n'
        return retval.rstrip('\n')
1108324
def print_formatted(datas):
    
    if not datas:
        print("No data")
        exit(1)

    if isinstance(datas, list):
        # get all zones
        # API /zone without :identifier
        hr()
        print('%-20s %-8s %-12s'
              % ('name', 'type', 'notified_serial'))
        hr()
        for record in datas:

            # print 'NAME'
            utils.print_inline("%(name)-20s" % record)

            # print 'TYPE' of SOA record
            utils.print_inline("%(type)-8s" % record)

            if record.get('notified_serial'):
                print("%(notified_serial)s" % record)
            else:
                print('')

        exit(0)

    elif datas.get('records'):
        print("domain: %(name)s" % datas)

        if datas.get('type') == 'MASTER' and datas.get('notified_serial'):
            print("serial: %(notified_serial)s" % datas)

        print("DNS   : %(type)s" % datas)

        # print header
        hr()
        print('%-33s %-5s %-25s %-5s %-3s'
              % ('name', 'type', 'content', 'ttl', 'prio'))
        hr()

        for record in datas.get('records'):

            # print 'NAME'
            utils.print_inline("%(name)-33s" % record)

            # print 'TYPE' of SOA record
            if record.get('type') == 'SOA':
                print("%(type)-5s" % record)

            # print 'TYPE' of non SOA record
            else:
                utils.print_inline("%(type)-5s" % record)

            # print 'CONTENT' of non SOA
            if record.get('type') == 'SOA':
                utils.print_inline(">\t\t%(content)-25s " % record)

            # print 'CONTENT' of SOA record
            else:
                utils.print_inline("%(content)-25s" % record)

            # print TTL, and PRIORITY for MX, SRV record
            if record.get('priority'):
                utils.print_inline("%(ttl)5s" % record)
                print("%(priority)2s" % record)

            # print ttl for non SOA record
            else:
                print("%(ttl)5s " % record)

        hr()

    elif datas.get('identifier'):
        # for template
        print("identifier : %(identifier)s" % datas)
        print("description: %(description)s" % datas)
        hr()
        print('%-33s %-5s %-25s %-5s %-3s'
              % ('name', 'type', 'content', 'ttl', 'prio'))

        for record in datas.get('entries'):

            # print 'NAME'
            utils.print_inline("%(name)-33s" % record)

            # print 'TYPE' for SOA
            if record.get('type') == 'SOA':
                print("%(type)-5s" % record)

            # print 'TYPE' for non SOA
            else:
                utils.print_inline("%(type)-5s" % record)

            # print 'CONTENT' for SOA
            if record.get('type') == 'SOA':
                utils.print_inline("> %(content)-25s " % record)

            # print 'CONTENT' for non SOA
            else:
                utils.print_inline("%(content)-24s" % record)

            # print 'TTL', and 'PRIORITY'
            if record.get('priority') is not None:
                utils.print_inline("%(ttl)5s" % record)
                print("%(priority)2s" % record)

            # print
            else:
                print("%(ttl)5s " % record)
        hr()
    else:
        print("No match records")
537887
def _raw(s):
    """"""

    if isinstance(s, list):
        s = "\n".join(_raw(item) for item in s)

    if s == EOF:
        return "EOF"

    s = repr(s)  # Get raw representation of string
    s = s[1:-1]  # Strip away quotation marks
    if len(s) > 15:
        s = s[:15] + "..."  # Truncate if too long
    return s