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.

Diff revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

1 2
1 2

  1. autobuild/common.py: Loading...
autobuild/common.py
Revision f49808fe3c07 New Change
... 95 lines hidden [Expand]
def get_current_user():
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:
105
    if not scp:
106
        raise AutobuildError("cannot find an appropriate scp or pscp command")
106
        logger.warning("cannot find an appropriate scp or pscp command; some packages may not be accessible")

   
107
        scp = 'NOSCPFOUND'
107
    return scp
108
    return scp
108

   
109

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

   
116

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

   
410

   
410
    def do_scp(self, remote):
411
    def do_scp(self, remote):
411
        if not self._dir:
412
        if not self._dir:
412
            self._dir = tempfile.mkdtemp()
413
            self._dir = tempfile.mkdtemp()
413
        local = os.path.join(self._dir, remote.split('/')[-1])
414
        local = os.path.join(self._dir, remote.split('/')[-1])

   
415
        if self._scp == 'NOSCPFOUND':

   
416
            raise AutobuildError("no scp command available; cannot fetch %s" % remote)
414
        command = (self._scp, remote, local)
417
        command = (self._scp, remote, local)
415
        rv = subprocess.call(command)
418
        rv = subprocess.call(command)
416
        if rv != 0:
419
        if rv != 0:
417
            raise AutobuildError("cannot fetch %s" % remote)
420
            raise AutobuildError("cannot fetch %s" % remote)
418
        return file(local, 'rb')
421
        return file(local, 'rb')
419

   
422

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

   
426

   
... 153 lines hidden [Expand]
  1. autobuild/common.py: Loading...