0

The collect static runs fine when it is executed manually from the command line, but it fails with sentry's built-in git function

But I know this is not sentry problem, because the problem occurs when I use gitpython to retrieve the git path

 source /home/ubuntu/.virtualenvs/myproject/bin/activate && python /home/ubuntu/myproject/manage.py collectstatic -v 1 --noinput
Traceback (most recent call last):
  File "/home/ubuntu/myproject/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
    settings.INSTALLED_APPS
  File "/home/ubuntu/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/home/ubuntu/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/ubuntu/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ubuntu/myproject/myproject/settings/prod.py", line 100, in <module>
    "release": raven.fetch_git_sha(os.path.dirname(os.pardir)),
  File "/home/ubuntu/.virtualenvs/myproject/local/lib/python2.7/site-packages/raven/versioning.py", line 25, in fetch_git_sha
    'Cannot identify HEAD for git repository at %s' % (path,))
raven.exceptions.InvalidGitRepository: Cannot identify HEAD for git repository at 

Here is another example where fabric would fail while the local execution will be okay:

from git import Repo 
from . import appname
import os 
print appname.__path__                          
base_dir = os.path.dirname(appname.__path__[0]) 
repo = Repo(base_dir)                           
dt = repo.head.commit.committed_date            

the appname's path will be empty. I am using from fabric.context_managers import cd for all my fabric tasks.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Forethinker
  • 3,548
  • 4
  • 27
  • 48
  • 1
    This has nothing to do with Git at all. I don't use `fabric` myself so am not sure if there are fabric-specific items here, but `from . import appname` in Python is something you do in a *package*, and `__path__` is specific to packages: see http://stackoverflow.com/a/25344804/1256452. The *package itself* has a path but `appname.__path__` (in your second example) is invalid: there is no `appname.__path__`. – torek Nov 07 '16 at 04:49
  • @torek You are right. I was passing a wrong value for the current path – Forethinker Nov 07 '16 at 06:08

0 Answers0