Not to overstep by jumping into this conversation, but I just wanted to
mention that os.path.expandvars should expand all environment variables
found in a string no matter the position.


On Tue, Apr 22, 2014 at 1:05 PM, Manne Öhrström <notifications@github.com>wrote:

> In python/tank/deploy/tank_commands/move_studio.py:
>
> > @@ -122,6 +122,16 @@ def update_pipeline_config(self, log, shotgun_pc_data, current_studio_paths, new
> >              try:
> >                  fh = open(studio_linkback_files[x], "rt")
> >                  data = fh.read().strip() # remove any whitespace, keep text
> > +                # check if env vars are used in the files instead of explicit paths
> > +                if data.startswith('$'):
> > +                    log.debug("Trying to move config specified by env variable %s" % data)
> > +                    try:
> > +                        data = os.environ[data[1:]]
> > +                        log.debug("expanded env variable to => %s" % (data))
> > +                    except KeyError:
> > +                        # we still want to raise the default exception
> > +                        log.warning('Envrionment variable %s does not exist' % data)
>
> Sounds good!! As for the if "$" in data comment - later in the code you
> are chopping off the first character - how were you thinking that
> occurrences of $ other than as the first character in the string would be
> handled? Isn't it better to keep it simple and just check like you
> currently do with if data.startswith('$') ?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/shotgunsoftware/tk-core/pull/69/files#r11863856>
> .
>



-- 
-tony