All submissions to this site are governed by the Second Life Viewer Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.

Review Board 1.6.11

Welcome to the Second Life Viewer Code Review tool.
See the documentation on our wiki for how to use this site.

Do not fail when no scp command is found, unless it is actually needed to fetch something

Review Request #127 - Created Jan. 28, 2011 and submitted

Oz Linden Reviewers
viewer
None autobuild
During initialization, if there is no scp or pscp command found then autobuild fails immediately.  This is true whether or not any scp urls need to be used.

This change modifies the behavior so that a warning is printed if no command is found, but execution proceeds until an scp command is needed, at which time execution fails with an explanatory message.

This patch can print the warning multiple times - I didn't attempt to suppress the extras.
I've tested this locally, simulating the error by temporarily modifying the names of the commands to be found for scp.

I have not checked it on Windows, where the original problem was found.

Changes between revision 1 and 2

1 2
1 2

  1. autobuild/common.py: Loading...
autobuild/common.py
Diff Revision 1 Diff Revision 2
... 94 lines hidden [Expand]
def get_current_user():
95
        namelen = ctypes.c_int(len(name)) # len in chars, NOT bytes
95
        namelen = ctypes.c_int(len(name)) # len in chars, NOT bytes
96
        if not ctypes.windll.advapi32.GetUserNameW(name, ctypes.byref(namelen)):
96
        if not ctypes.windll.advapi32.GetUserNameW(name, ctypes.byref(namelen)):
97
            raise ctypes.WinError()
97
            raise ctypes.WinError()
98
        return name.value
98
        return name.value
99

   
99

   
100
def get_default_scp_command():
100
def get_default_scp_command():
101
    """
101
    """
102
    Return the full path to the scp command
102
    Return the full path to the scp command
103
    """
103
    """
104
    scp = find_executable(['pscp', 'scp'], ['.exe'])
104
    scp = find_executable(['pscp', 'scp'], ['.exe'])
105
    if not scp:

   
106
        logger.warning("cannot find an appropriate scp or pscp command; some packages may not be accessible")

   
107
        scp = 'NOSCPFOUND'

   
108
    return scp
105
    return scp
109

   
106

   
110
def get_default_install_cache_dir():
107
def get_default_install_cache_dir():
111
    """
108
    """
112
    In general, the package archives do not change much, so find a 
109
    In general, the package archives do not change much, so find a 
113
    host/user specific location to cache files.
110
    host/user specific location to cache files.
114
    """
111
    """
115
    return get_temp_dir("install.cache")
112
    return get_temp_dir("install.cache")
116

   
113

   
117
def get_s3_url():
114
def get_s3_url():
... 287 lines hidden [Expand]
def do_http(self, remote):
405
            url.insert(1, '/')
402
            url.insert(1, '/')
406
        url.insert(0, "http://")
403
        url.insert(0, "http://")
407
        url = ''.join(url)
404
        url = ''.join(url)
408
        logger.info("using HTTP: " + url)
405
        logger.info("using HTTP: " + url)
409
        return urllib2.urlopen(url)
406
        return urllib2.urlopen(url)
410

   
407

   
411
    def do_scp(self, remote):
408
    def do_scp(self, remote):
412
        if not self._dir:
409
        if not self._dir:
413
            self._dir = tempfile.mkdtemp()
410
            self._dir = tempfile.mkdtemp()
414
        local = os.path.join(self._dir, remote.split('/')[-1])
411
        local = os.path.join(self._dir, remote.split('/')[-1])
415
        if self._scp == 'NOSCPFOUND':
412
        if not self._scp:
416
            raise AutobuildError("no scp command available; cannot fetch %s" % remote)
413
            raise AutobuildError("no scp command available; cannot fetch %s" % remote)
417
        command = (self._scp, remote, local)
414
        command = (self._scp, remote, local)

   
415
        logger.info("using SCP: " + remote)
418
        rv = subprocess.call(command)
416
        rv = subprocess.call(command)
419
        if rv != 0:
417
        if rv != 0:
420
            raise AutobuildError("cannot fetch %s" % remote)
418
            raise AutobuildError("cannot fetch %s" % remote)
421
        return file(local, 'rb')
419
        return file(local, 'rb')
422

   
420

   
423
    def cleanup(self):
421
    def cleanup(self):
424
        if self._dir:
422
        if self._dir:
425
            shutil.rmtree(self._dir)
423
            shutil.rmtree(self._dir)
426

   
424

   
427
#
425
#
... 152 lines hidden [Expand]
  1. autobuild/common.py: Loading...