~fginther/landscape-client/fix-missing-install-dirs

« back to all changes in this revision

Viewing changes to landscape/deployment.py

  • Committer: 🤖 Landscape Builder
  • Author(s): Eric Snow
  • Date: 2017-04-05 14:44:54 UTC
  • mfrom: (984.1.13 fix-test-race-sys-argv)
  • Revision ID: _landscape_builder-20170405144454-kjfd61vyk1nz6b2t
Merge fix-test-race-sys-argv [f=1677630] [r=free.ekanayaka,simpoir] [a=Eric Snow]
his patch fixes a race condition in tests involving sys.argv.

Under certain load conditions there is a collision on patched-out
sys.argv. To resolve this, we switch to using the config to store the
bindir that should be used (rather than extrapolating from sys.argv[0]).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
 
2
import os.path
2
3
import sys
3
4
 
4
5
from configobj import ConfigObj, ConfigObjError
432
433
        upgrade_manager.initialize(persist)
433
434
    persist.save(service.persist_filename)
434
435
    return persist
 
436
 
 
437
 
 
438
def get_bindir(config=None):
 
439
    """Return the directory path where the client binaries are.
 
440
 
 
441
    If the config is None, it doesn't have a "bindir" attribute, or its
 
442
    value is None, then sys.argv[0] is returned.
 
443
    """
 
444
    try:
 
445
        bindir = config.bindir
 
446
    except AttributeError:  # ...also the result if config is None.
 
447
        bindir = None
 
448
    if bindir is None:
 
449
        bindir = os.path.dirname(os.path.abspath(sys.argv[0]))
 
450
    return bindir