Example #1
0
    def __init__(self, host, **kwargs):
        sys.stdout.flush()
        sys.stdin.flush()
        self.tunnel = core.connect(host)
        rport = self.tunnel._rport

        link = (host, rport)

        self.session = core.execute(link, host)

        self.host = host
        self.local_server = 'localhost:%d' % self.tunnel._lport
        self.remote_server = '%s:%d' % (host, self.tunnel._rport)
        self.pid = core.getpid(host)

        password = str(self.tunnel._lport) + str(self.pid)  #create secret code
        servers = [server, server_2, server_3]
        passwords = ['']
        for i in range(len(servers)):
            passwords = check_password(servers, passwords, password)

        sys.stdout.flush()
        sys.stdin.flush()
        print('SSH tunnel from:  %s -> to: %s,' %
              (self.local_server, self.remote_server))
        print('pid %d' % self.pid)
  # my remote environment (should be auto-detected)
  register_profiles(profiles)
  profile = get_profile(rhost)

##### CONFIGURATION & INPUT ########################

  file = 'install-%s-%s.sh' % (package,version)
  # XXX: should use easy_install, if is installed...

  import tempfile
# tempfile.tempdir = "~" #XXX: uncomment if cannot install to '/tmp'
  dest = tempfile.mktemp()+"_install" #XXX: checks local (not remote)

  # check for existing installation
  command = "source %s; python -c 'import %s'" % (profile,package)
  error = execute(command,rhost).response()
  if error in ['', None]:
    print('%s is already installed on %s' % (package,rhost))
# elif error[:39] == 'This system is available for legitimate use'[:39] \
#      and rhost[:3] == 'shc-b.cacr.caltech.edu'[:3]:
##     and error[-35:-1] == 'an authorized user of this system.'[-35:] \
#   print('%s is already installed on %s' % (package,rhost))
    #XXX: could parse 'error' for "ImportError" ==> not installed
    #XXX: could use command="python -c 'import X; X.__version__'"
    #XXX  ...returns version# or "AttributeError" ==> non-standard version tag
  else:
    print(error)
    sleep(delay)

    # create install directory
    command = 'mkdir -p %s' % dest #FIXME: *nix only
Example #3
0
    def __init__(self, hostname, **kwargs):

        import sys
        sys.stdout.flush()
        sys.stdin.flush()

        self.tunnel = PC.connect(hostname)
        remport = self.tunnel._rport

        import sys
        sys.stdout.flush()
        sys.stdin.flush()

        self.input = open('/dev/null', 'r')

        import pp
        the_file = pp.__file__
        the_dir = os.path.dirname(the_file)
        the_server = the_dir + '/scripts/ppserver.py'  ## NB!!!

        secret = kwargs.pop('secret', '')

        if not secret:
            command = """
            export PYTHONPATH=%s
            export PATH=%s
            export LD_LIBRARY_PATH=%s        
            export LD_PRELOAD=%s        
            %s -p%d
            """ % (os.environ['PYTHONPATH'], os.environ['PATH'],
                   os.environ['LD_LIBRARY_PATH'],
                   os.environ.get('LD_PRELOAD', ''), the_server, remport)
        else:
            command = """
            export PYTHONPATH=%s
            export PATH=%s
            export LD_LIBRARY_PATH=%s        
            export LD_PRELOAD=%s        
            %s -p%d -s%s 
            """ % (os.environ['PYTHONPATH'], os.environ['PATH'],
                   os.environ['LD_LIBRARY_PATH'],
                   os.environ.get('LD_PRELOAD',
                                  ''), the_server, remport, secret)

        ## execute the command!
        self.session = PC.execute(command,
                                  hostname,
                                  options='-q -T',
                                  stdin=self.input,
                                  bg=True)

        r = self.session.response()
        if self.session._stdout:
            self.session._stdout.flush()

        import time
        time.sleep(0.2)  ## sleep...

        self.hostname = hostname
        self.local_server = 'localhost:%d' % self.tunnel._lport
        self.remote_server = '%s:%d' % (hostname, self.tunnel._rport)

        target = '[P,p]ython[^#]*' + 'ppserver'
        self.pid = PC.getpid(target, hostname)

        sys.stdout.flush()
        sys.stdin.flush()
        logger.debug('SSH tunnel:  %s <--> %s , #PID %d' %
                     (self.local_server, self.remote_server, self.pid))
Example #4
0
  # my remote environment (should be auto-detected)
  register_profiles(profiles)
  profile = get_profile(rhost)

##### CONFIGURATION & INPUT ########################

  file = 'install-%s-%s.sh' % (package,version)
  # XXX: should use easy_install, if is installed...

  import tempfile
# tempfile.tempdir = "~" #XXX: uncomment if cannot install to '/tmp'
  dest = tempfile.mktemp()+"_install" #XXX: checks local (not remote)

  # check for existing installation
  command = "source %s; python -c 'import %s'" % (profile,package)
  error = execute(command,rhost).response()
  if error in ['', None]:
    print('%s is already installed on %s' % (package,rhost))
# elif error[:39] == 'This system is available for legitimate use'[:39] \
#      and rhost[:3] == 'shc-b.cacr.caltech.edu'[:3]:
##     and error[-35:-1] == 'an authorized user of this system.'[-35:] \
#   print('%s is already installed on %s' % (package,rhost))
    #XXX: could parse 'error' for "ImportError" ==> not installed
    #XXX: could use command="python -c 'import X; X.__version__'"
    #XXX  ...returns version# or "AttributeError" ==> non-standard version tag
  else:
    print(error)
    sleep(delay)

    # create install directory
    command = 'mkdir -p %s' % dest #FIXME: *nix only