mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 11:20:39 -03:30
Fix up unicode project directory issue, with unit tests
This commit is contained in:
parent
d410e1aa2c
commit
9e962d4d5b
@ -54,7 +54,7 @@ class ProjectOptions(models.Model):
|
||||
@classmethod
|
||||
def get_local_path_choices(cls):
|
||||
if os.path.exists(settings.PROJECTS_ROOT):
|
||||
paths = [x for x in os.listdir(settings.PROJECTS_ROOT)
|
||||
paths = [x.decode('utf-8') for x in os.listdir(settings.PROJECTS_ROOT)
|
||||
if os.path.isdir(os.path.join(settings.PROJECTS_ROOT, x))
|
||||
and not x.startswith('.') and not x.startswith('_')]
|
||||
qs = Project.objects.filter(active=True)
|
||||
|
||||
@ -174,11 +174,15 @@ class BaseTestMixin(object):
|
||||
return results
|
||||
|
||||
def make_project(self, name, description='', created_by=None,
|
||||
playbook_content='', role_playbooks=None):
|
||||
playbook_content='', role_playbooks=None, unicode_prefix=True):
|
||||
if not os.path.exists(settings.PROJECTS_ROOT):
|
||||
os.makedirs(settings.PROJECTS_ROOT)
|
||||
# Create temp project directory.
|
||||
project_dir = tempfile.mkdtemp(dir=settings.PROJECTS_ROOT)
|
||||
if unicode_prefix:
|
||||
tmp_prefix = u'\u2620tmp'
|
||||
else:
|
||||
tmp_prefix = 'tmp'
|
||||
project_dir = tempfile.mkdtemp(prefix=tmp_prefix, dir=settings.PROJECTS_ROOT)
|
||||
self._temp_paths.append(project_dir)
|
||||
# Create temp playbook in project (if playbook content is given).
|
||||
if playbook_content:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user