Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing pull_translations without a locale path setting gives an exception #20

Open
willharris opened this issue Nov 19, 2015 · 0 comments

Comments

@willharris
Copy link

When I run

./manage.py tx pull_translations

without having specified TRANSIFEX_PROJECT_PATH in the settings I get the following exception:

Executing pull_translations on project test-392
Pulling translations for "test-392" project, in "en" source language
Traceback (most recent call last):
  File "./manage.py", line 7, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/harris/Workspaces/Unleash12/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/harris/Workspaces/Unleash12/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/harris/Workspaces/Unleash12/env/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/harris/Workspaces/Unleash12/env/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Users/harris/Src/django-transifex/djangotransifex/management/commands/tx.py", line 75, in handle
    command_func(*args[1:], **options)
  File "/Users/harris/Src/django-transifex/djangotransifex/management/commands/tx.py", line 159, in transifex_pull_translations
    project_slug=self.project_slug, source_language=self.source_language
  File "/Users/harris/Src/django-transifex/djangotransifex/api.py", line 171, in pull_translations
    'LC_MESSAGES'
  File "/Users/harris/Workspaces/Unleash12/env/bin/../lib/python2.7/posixpath.py", line 70, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'function' object has no attribute 'endswith'

This is with Django 1.6.

It seems that if the path is not explicitly set, then django-transifex tries to figure out where the project is located using a lazy function. There are two problems in the code:

  • the lazy function is not properly initialized - it needs str as an additional parameter.
  • the lazy function is not a property but a callable, and is not evaluated on access.

There is also the problem that the actual helper function app_settings._get_project_path does not handle the case where the settings file is not top-level in the project. In my case, all my settings are stored in a submodule structure.

The tests do not catch this, because the tests explicitly define TRANSIFEX_PROJECT_PATH.

willharris added a commit to willharris/django-transifex that referenced this issue Nov 19, 2015
…he location of the locales, rather than trying to figure out the project path from the settings module. Allow specifying a custom locale path for operations using a command-line flag. (Issue jakul#20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant