Esempio n. 1
0
def reset_error():
    """
    >> reset_error
    
    Reset twill error output to go to the screen.
    """
    import twill
    twill.set_errout(None)
Esempio n. 2
0
def reset_error():
    """
    >> reset_error
    
    Reset twill error output to go to the screen.
    """
    import twill
    twill.set_errout(None)
Esempio n. 3
0
def redirect_error(filename):
    """
    >> redirect_error <filename>

    Append all twill error output to the given file.
    """
    import twill
    fp = open(filename, 'a')
    twill.set_errout(fp)
Esempio n. 4
0
def redirect_error(filename):
    """
    >> redirect_error <filename>

    Append all twill error output to the given file.
    """
    import twill
    fp = open(filename, 'a')
    twill.set_errout(fp)
Esempio n. 5
0
 def execute_script(self):
     """ Executes twill script. Returns a tuple status, output """
     out = StringIO()
     # execute the twill, catching any exceptions
     try:
         twill.set_errout(out)
         twill.set_output(out)
         twill.parse._execute_script(self.watch.script.split("\n"))
         status = STATUS_OK
     except Exception, e:
         status = STATUS_FAILED
Esempio n. 6
0
def enable_debug(debug):
    if isinstance(debug, bool) or debug is None:
        if debug:
            twillout = sys.stderr
        else:
            twillout = StringIO.StringIO()
    elif isinstance(debug, str):
        twillout = file(debug, 'a')
    else:
        raise ValueError, debug

    import twill
    twill.set_output(twillout)
    twill.set_errout(twillout)
Esempio n. 7
0
def enable_debug(debug):
    if isinstance(debug, bool) or debug is None:
        if debug:
            twillout=sys.stderr
        else:
            twillout=StringIO.StringIO()        
    elif isinstance(debug, str):
        twillout=file(debug, 'a')
    else:
        raise ValueError, debug

    import twill
    twill.set_output(twillout)
    twill.set_errout(twillout)
Esempio n. 8
0
    def setUp(self):
        self.twillOutput = StringIO()
        self.twillErr = StringIO()
        twill.set_output(self.twillOutput)
        twill.set_errout(self.twillErr)
        def get_open_port():
            import socket
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.bind(("",0))
            s.listen(1)
            port = s.getsockname()[1]
            s.close()
            return port
        self.server_port = get_open_port()

        # We need something to feed the server as a realm, but it needn't
        # be reachable.  (Until we test realm verification.)
        self.realm = 'http://127.0.0.1/%s' % (self.id(),)
        self.return_to = self.realm + '/return_to'

        twill.commands.reset_browser()
Esempio n. 9
0
        self.fstream.write(spacing + msg)

    def indent(self):
        self.indentation += 1
    def outdent(self):
        self.indentation -= 1
        if self.indentation < 0:
            self.indentation = 0

# this controls what messages to allow through
def output_pred(msg):
    return msg.strip()

def make_log_fn(output_stream, prepend_string, pred):
    def log_fn(msg):
        if pred(msg):
            output_stream.write(prepend_string + msg)
    return log_fn

# this is where all output will go
output_stream = IndentedStream(output_pred=output_pred)

# flunc uses these for output
log_error = make_log_fn(output_stream, '[X] ', output_pred)
log_warn = make_log_fn(output_stream, '[!] ', output_pred)
log_info = make_log_fn(output_stream, '[*] ', output_pred)

# and these hook in flunc's output
set_output(output_stream)
set_errout(output_stream)
Esempio n. 10
0
 def tearDown(self):
     twill.set_output(None)
     twill.set_errout(None)
Esempio n. 11
0
    def outdent(self):
        self.indentation -= 1
        if self.indentation < 0:
            self.indentation = 0


# this controls what messages to allow through
def output_pred(msg):
    return msg.strip()


def make_log_fn(output_stream, prepend_string, pred):
    def log_fn(msg):
        if pred(msg):
            output_stream.write(prepend_string + msg)

    return log_fn


# this is where all output will go
output_stream = IndentedStream(output_pred=output_pred)

# flunc uses these for output
log_error = make_log_fn(output_stream, '[X] ', output_pred)
log_warn = make_log_fn(output_stream, '[!] ', output_pred)
log_info = make_log_fn(output_stream, '[*] ', output_pred)

# and these hook in flunc's output
set_output(output_stream)
set_errout(output_stream)
Esempio n. 12
0
import glob
import subprocess
import time
import tempfile
import datetime
from getpass import getpass

# twill's __init__.py is dumb, we need to work around it to play nice
# with jupyter:
import sys
_stdout = sys.stdout
_stderr = sys.stdout

import twill
twill.set_output(_stdout)
twill.set_errout(_stderr)
twill.set_loglevel(twill.loglevels['WARNING'])

import pexpect
import paramiko

import numpy as np

from maven_iuvs.miscellaneous import clear_line
from maven_iuvs.search import get_filename_glob_string, get_latest_files


def get_user_paths_filename():
    """
    Determines whether user_paths.py exists and returns the filename
    if it does.