0

我正在 Windows 机器上开发基于 django 的站点,但我将更改推送到无头 Ubuntu 服务器以用于暂存目的。当我 git 将更改拉入登台服务器上的工作目录时,我需要运行 manage.py collectstatic。但是,当我这样做时,更改监视器(重新加载源代码的“监视代码更改”部分)报告它已检测到更改的文件:

monitor (pid=26216): Starting change monitor.

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: monitor (pid=26216): Change detected to 'myproject/manage.py'.
monitor (pid=26216): Triggering process restart.
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
    output = self.handle(*args, **options)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 385, in handle
    return self.handle_noargs(**options)
  File "/envs/myproject/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 160, in handle_noargs
    % (destination_display, clear_display))
KeyboardInterrupt

我运行“touch myproject/wsgi.py”来“更新更改缓存”,然后再次运行 collectstatic 命令。这导致了同样的错误。

然后我进入 python 控制台并手动运行监视器启动命令:

import myproject.monitor
myproject.monitor.start(1)

这没什么区别。我还尝试向监视器添加一个条件,以便在检查文件更改时忽略 manage.py 但这只是给了我与 myproject/__init__.py 报告为已更改的文件相同的错误。有谁知道是什么原因造成的?

4

1 回答 1

1

我已经弄清楚是什么原因造成的。旧文件修改时间作为带小数位的 unix 时间戳(例如 1366283624.92)保存在字典中,而实际修改时间os.stat(path).st_mtime作为整数返回。我所要做的就是在第 54 行编辑监控脚本,更改:

if mtime != _times[path]:

if int(mtime) != int(_times[path]):

我只是希望这不会导致任何进一步的问题

于 2013-06-05T14:30:48.773 回答