首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >伪依赖文件在本地中失败

伪依赖文件在本地中失败
EN

Stack Overflow用户
提问于 2016-08-25 12:20:43
回答 1查看 234关注 0票数 0

下面是应用程序的伪代码。

代码语言:javascript
复制
class ltp ($project_dir = '/vagrant') {

    exec {
        "install_project_dependencies":
            cwd => $project_dir,
            command => "/usr/bin/python setup.py install > /tmp/setuplog 2>&1",
            timeout => 0,
    }

    exec {
        "install_nltk_data":
            cwd => $project_dir,
            command => "su - vagrant -c \"cd /opt/vagrant; /usr/bin/python -m nltk.downloader stopwords > /tmp/nltklog 2>&1\"",
            require => Exec['install_project_dependencies']
    }

    exec {
        "install_django_db":
            cwd => $project_dir,
            user => 'vagrant',
            environment => ["ENV=DEV"],
            command => "/usr/bin/python manage.py syncdb --noinput > /tmp/syncdblog 2>&1",
            require => Exec['create_ba_database']
    }

    exec {
        "create_ba_database":
            cwd => $project_dir,
            command => "echo \"psql -c 'create database burson_clips;'\" | sudo su postgres",
            require => Exec['change_pg_password']
    }

    exec {
        "change_pg_password":
            cwd => $project_dir,
            command => "sudo -u postgres psql -c \"alter user postgres with password 'postgres';\""
    }

} 

下面是运行vagrant provision时出现的错误值

代码语言:javascript
复制
clips: Error: /usr/bin/python setup.py install > /tmp/setuplog 2>&1 returned 1 instead of one of [0]
==> clips: Error: /Stage[main]/Ltp/Exec[install_project_dependencies]/returns: change from notrun to 0 failed: /usr/bin/python setup.py install > /tmp/setuplog 2>&1 returned 1 instead of one of [0]
==> clips: Warning: /Stage[main]/Ltp/Exec[install_nltk_data]: Skipping because of failed dependencies
==> clips: Notice: /Stage[main]/Ltp/Exec[change_pg_password]/returns: executed successfully
==> clips: Notice: /Stage[main]/Ltp/Exec[create_ba_database]/returns: ERROR:  database "burson_clips" already exists
==> clips: Notice: /Stage[main]/Ltp/Exec[install_django_db]: Dependency Exec[create_ba_database] has failures: true
==> clips: Error: echo "psql -c 'create database burson_clips;'" | sudo su postgres returned 1 instead of one of [0]
==> clips: Error: /Stage[main]/Ltp/Exec[create_ba_database]/returns: change from notrun to 0 failed: echo "psql -c 'create database burson_clips;'" | sudo su postgres returned 1 instead of one of [0]
==> clips: Warning: /Stage[main]/Ltp/Exec[install_django_db]: Skipping because of failed dependencies

以前有没有人收到过这个错误?有谁能让我知道是否有任何代码领域我应该调查。这种情况发生在我当地的流浪汉设置上。

更新

因此,我尝试了Vagrant并重新创建了依赖关系,现在我得到了错误。

代码语言:javascript
复制
==> clips: Error: /usr/bin/python setup.py install > /tmp/setuplog 2>&1 returned 1 instead of one of [0]
==> clips: Error: /Stage[main]/Ltp/Exec[install_project_dependencies]/returns: change from notrun to 0 failed: /usr/bin/python setup.py install > /tmp/setuplog 2>&1 returned 1 instead of one of [0]
==> clips: Warning: /Stage[main]/Ltp/Exec[install_nltk_data]: Skipping because of failed dependencies
==> clips: Notice: /Stage[main]/Ltp/Exec[change_pg_password]/returns: executed successfully
==> clips: Notice: /Stage[main]/Ltp/Exec[create_ba_database]/returns: executed successfully
==> clips: Error: /usr/bin/python manage.py syncdb --noinput > /tmp/syncdblog 2>&1 returned 1 instead of one of [0]
==> clips: Error: /Stage[main]/Ltp/Exec[install_django_db]/returns: change from notrun to 0 failed: /usr/bin/python manage.py syncdb --noinput > /tmp/syncdblog 2>&1 returned 1 instead of one of [0]

添加setup.py

代码语言:javascript
复制
#!/usr/bin/env python
from setuptools import setup

# fix setuptools:
# wget http://bootstrap.pypa.io/ez_setup.py -O - | sudo python

install_requires = [
    'Django==1.8',
    'django-celery',
    'celery==3.1.23',
    'ipdb',
    # 'ipython',
    'django-kombu',
    'kombu',
    'billiard',
    'eventlet',
    #    'uwsgi',
    'xlutils',
    'pip-tools',
    'djangorestframework',
    'markdown',
    'django-filter',
    'django-cors-headers',
    'pyyaml',
    'sh',
    'pika==0.9.12',
    'pyparsing',
    'pyrabbit',
    'lxml==3.3.5',
    'xlrd',
    'raven',
    'six',
    'requests',
    'uritemplate',
    'twitter-text-python',  # for the ttp

    'python-dateutil==2.4.0',
    'redis',
    'python-docx',  ##for opening word documents
    'sqlparse',
    'httplib2',
    'simplejson',
    'requests==2.5.1',
    'six>=1.7.3',
    'django-organizations',
    'django_extensions',
    'feedparser==5.1.3',

    # The entry for this on pypi is f'd up.
    # pip install https://github.com/timothycrosley/RedisStore/blob/master/dist/RedisStore-0.1.tar.gz?raw=true
    # 'RedisStore',


    'xlsxwriter',
    'django-grappelli',

    # MDM: setuptools/pip can't install these
    # 'gensim',
    # 'numpy',
    # 'scikit-learn',
    # 'matplotlib',

    # MDM: only pip can install this one!
    # 'CairoSVG',

    'xmltodict',
    'twitter',
    'pygal',
    'tinycss',
    'cssselect',
    'dashboard_common==1.3.3',
    'pytz',
    'greenlet',
    'xlsxwriter',
    'pattern',
    'oauth2',

    'wordcloud',

    # MDM this is a dep-lib cluser-f
    # pip install it last so it can f up dependencies how ever it likes
    # 'python-social-auth',
    # 'newspaper', ##for article extraction

    'python-saml',
    'python-openid',
    'xmlsec',
    'paramiko',

    # has apt-get/brew deps
    'psycopg2'
]


# sudo -H pip install CairoSVG

dependency_links = [
    # fails unless vagrant box has a .ssh identity w/ git hub & trust github
    'workinggithublink',

]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-25 12:26:59

错误是:

代码语言:javascript
复制
==> clips: Notice: /Stage[main]/Ltp/Exec[create_ba_database]/returns: ERROR:  database "burson_clips" already exists

==> clips: Error: echo "psql -c 'create database burson_clips;'" | sudo su postgres returned 1 instead of one of [0]

您的db已经以burson_clips的形式存在,因此命令失败,其余的配置失败。

您应该能够利用来自Check if database exists in PostgreSQL using shell的一些答案来首先检查db是否存在,然后只在需要时创建;例如

代码语言:javascript
复制
exec {
    "create_ba_database":
        cwd => $project_dir,
        command => "echo \"psql -c 'create database burson_clips;'\" | sudo su postgres",
        require => Exec['change_pg_password'],
        unless => "psql -lqt | cut -d \| -f 1 | grep -qw 'burson_clips'"
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39145182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档