예제 #1
0
def view_with_less(content, color=True):
    """Send `content` through less."""
    import subprocess
    cmd = ['less']
    if color:
        cmd.append('-r')

    less_proc = subprocess.Popen(cmd, stdin=subprocess.PIPE)
    less_proc.stdin.write(maybe_encode(content))
    less_proc.stdin.close()
    less_proc.wait()
예제 #2
0
파일: display.py 프로젝트: Yelp/Tron
def view_with_less(content, color=True):
    """Send `content` through less."""
    import subprocess
    cmd = ['less']
    if color:
        cmd.append('-r')

    less_proc = subprocess.Popen(cmd, stdin=subprocess.PIPE)
    less_proc.stdin.write(maybe_encode(content))
    less_proc.stdin.close()
    less_proc.wait()
예제 #3
0
    def write(self, content):
        """Write content to the fh. Re-open if necessary."""
        if self._fh == NullFileHandle:
            try:
                self._fh = open(self.name, 'ab')
            except IOError as e:
                log.error("Failed to open %s: %s", self.name, e)
                return

        self.last_accessed = time.time()
        self._fh.write(maybe_encode(content))
        self.manager.update(self)
예제 #4
0
    def write(self, content):
        """Write content to the fh. Re-open if necessary."""
        if self._fh == NullFileHandle:
            try:
                self._fh = open(self.name, 'ab')
            except IOError as e:
                log.error("Failed to open %s: %s", self.name, e)
                return

        self.last_accessed = time.time()
        self._fh.write(maybe_encode(content))
        self.manager.update(self)
예제 #5
0
파일: manager.py 프로젝트: Yelp/Tron
def hash_digest(content):
    return hashlib.sha1(maybe_encode(content)).hexdigest()
예제 #6
0
def hash_digest(content):
    return hashlib.sha1(maybe_encode(content)).hexdigest()