mirror of
https://github.com/ansible/awx.git
synced 2026-03-20 18:37:39 -02:30
Fix up unicode project directory issue, with unit tests
This commit is contained in:
@@ -54,7 +54,7 @@ class ProjectOptions(models.Model):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_local_path_choices(cls):
|
def get_local_path_choices(cls):
|
||||||
if os.path.exists(settings.PROJECTS_ROOT):
|
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))
|
if os.path.isdir(os.path.join(settings.PROJECTS_ROOT, x))
|
||||||
and not x.startswith('.') and not x.startswith('_')]
|
and not x.startswith('.') and not x.startswith('_')]
|
||||||
qs = Project.objects.filter(active=True)
|
qs = Project.objects.filter(active=True)
|
||||||
|
|||||||
@@ -174,11 +174,15 @@ class BaseTestMixin(object):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def make_project(self, name, description='', created_by=None,
|
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):
|
if not os.path.exists(settings.PROJECTS_ROOT):
|
||||||
os.makedirs(settings.PROJECTS_ROOT)
|
os.makedirs(settings.PROJECTS_ROOT)
|
||||||
# Create temp project directory.
|
# 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)
|
self._temp_paths.append(project_dir)
|
||||||
# Create temp playbook in project (if playbook content is given).
|
# Create temp playbook in project (if playbook content is given).
|
||||||
if playbook_content:
|
if playbook_content:
|
||||||
|
|||||||
Reference in New Issue
Block a user