Closed rpappalax closed 8 years ago
mozprofile give us: random path (we don't want) + random profile name but not just a random profile name (which is what we want) it will be easier for us to just create a new profile with a random name every time
Stealing from the mozprofile.profile code, it looks like they're just using this pseudo logic:
# https://docs.python.org/2/library/tempfile.html#tempfile.mkdtemp
from tempfile import mkdtemp
foo = mkdtemp(prefix='_', suffix='.fftool', dir='_temp/profiles')
print(foo) # _temp/profiles/_mKzlMz.fftool/*
So if the user doesn't specify a profile name, we can use mkdtemp
to create a random directory name in the specified dir
(in our case something like _temp/profiles
). Thankfully, we also have control over the prefix and suffix, so we can do something like ./_temp/profiles/_{RANDOM}.fftool/
so we can easily see which directories were created using random+generated names vs named profiles.
Basically if the user doesn't specify a directory name, we'll create a random directory in the ./_temp/profiles/ directory and set that directory name as the profile name. Easy peas.
This should have been fixed via #17. Ref: ./fftool/firefox_profile.py:61 wherein if a profile name was not explicitly passed in, we will create a new profile using "fftool.{sha}" (using mkdtemp).
A common use case for testing is to launch a 'fresh' profile, but not necessarily one with any particular name other than it be unique.
In that case, we should add a function to generate a random profile name.