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

Reintroduce postgres support #66

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
*~
*#
*.log
*.gz
/seafdav.conf
/seafdav.fcgi.conf
.cache
.coverage
.eggs
Expand Down
75 changes: 27 additions & 48 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,31 @@
# sudo: false
dist: bionic
language: python

matrix:
include:
- python: "2.7"
env: TOXENV=lint-py27
- python: "3.7"
env: TOXENV=black-check,lint-py3
dist: xenial # only while we're using python 3.7
- python: "2.7"
env: TOXENV=py27
# - python: "3.4" # EOL 2019-03-18
# env: TOXENV=py34
- python: "3.5"
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36
- python: "3.7"
env: TOXENV=py37
dist: xenial
- python: "3.8"
env: TOXENV=py38
- python: "3.7-dev"
env: TOXENV=py37
- python: "3.8-dev"
env: TOXENV=py38
allow_failures:
- python: "3.7-dev"
env: TOXENV=py37
- python: "3.8-dev"
env: TOXENV=py38

python:
- "3.6"
compiler:
- gcc
addons:
apt:
packages:
- valac
- uuid-dev
- libevent-dev
- libarchive-dev
- intltool
- libjansson-dev
- libonig-dev
- libfuse-dev
- net-tools
- libglib2.0-dev
- sqlite3
- libsqlite3-dev
- libonig-dev
- libcurl4-openssl-dev
before_install:
# See issue #80: litmus fails to build on travis
# The branch 'travis-litmus' still has this enabled to investigate...
# - sudo apt-get install libneon27-dev
# - ./install_litmus.sh

services:
- redis-server

- chmod +x ci/install-deps.sh
- chmod +x ci/functests.sh
- pip install -r ./ci/requirements.txt
install:
- travis_retry pip install -U pip setuptools
- travis_retry pip install -U tox coveralls coverage

- "./ci/install-deps.sh"
script:
- travis_retry tox

after_success:
- coverage combine
- coveralls
- "./ci/functests.sh init && ./ci/functests.sh runserver && ./ci/functests.sh test"
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
The MIT License

Copyright (c) 2009-2020 Martin Wendt, (Original PyFileServer (c) 2005 Ho Chun Wei)
Copyright (c) 2012-present Seafile Ltd.

Seafile webdav server is based on WsgiDAV.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all: seafdav.tar.gz

seafdav.tar.gz:
git archive HEAD wsgidav | gzip > seafdav.tar.gz
clean:
rm -f *.gz
91 changes: 22 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,31 @@
# ![logo](https://raw.githubusercontent.com/mar10/wsgidav/master/doc/logo.png) WsgiDAV
[![Build Status](https://travis-ci.org/mar10/wsgidav.svg?branch=master)](https://travis-ci.org/mar10/wsgidav)
[![Latest Version](https://img.shields.io/pypi/v/wsgidav.svg)](https://pypi.python.org/pypi/WsgiDAV/)
[![License](https://img.shields.io/pypi/l/wsgidav.svg)](https://github.com/mar10/wsgidav/blob/master/LICENSE)
[![Documentation Status](https://readthedocs.org/projects/wsgidav/badge/?version=latest)](http://wsgidav.readthedocs.io/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![StackOverflow: WsgiDAV](https://img.shields.io/badge/StackOverflow-WsgiDAV-blue.svg)](https://stackoverflow.com/questions/tagged/WsgiDAV)
# Seafile WebDAV Server [![Build Status](https://secure.travis-ci.org/haiwen/seafdav.svg?branch=master)](http://travis-ci.org/haiwen/seafdav)

A generic and extendable [WebDAV](http://www.ietf.org/rfc/rfc4918.txt) server
written in Python and based on [WSGI](http://www.python.org/dev/peps/pep-3333/).
This is the WebDAV server for seafile.

Main features:
See [Seafile Server Manual](http://manual.seafile.com/extension/webdav.html) for details.

- WsgiDAV is a stand-alone WebDAV server with SSL support, that can be
installed and run as Python command line script on Linux, OSX, and Windows:<br>
```
$ pip install wsgidav cheroot
$ wsgidav --host=0.0.0.0 --port=8080 --root=/tmp
WARNING: share '/' will allow anonymous access.
Running WsgiDAV/2.2.2 Cheroot/5.5.0 Python/3.4.2
Serving on http://0.0.0.0:8080 ...
```
Run `wsgidav --help` for a list of available options.<br>
**Note:** The syntax changed slightly with v3.0.
- **Note:** python-pam is needed if using pam-login on Linux or OSX:
```
$ pip install python-pam
$ wsgidav --auth=pam-login --host=0.0.0.0 --port=8080 --root=/tmp
```
- **Note:** Windows users may prefer the
[MSI Installer](https://github.com/mar10/wsgidav/releases/latest)
(see <kbd>Assets</kbd> section).
- WebDAV is a superset of HTTP, so WsgiDAV is also a performant, multi-threaded
web server with SSL support.
- WsgiDAV is also a Python library that implements the WSGI protocol and can
be run behind any WSGI compliant web server.<br>
- WsgiDAV is implemented as a configurable stack of WSGI middleware
applications.<br>
Its open architecture allows to extend the functionality and integrate
WebDAV services into your project.<br>
Typical use cases are:
- Expose data structures as virtual, editable file systems.
- Allow online editing of MS Office documents.
# Running

There are a template for running seafdav:
- run.sh.template: This is for running seafdav on the default 8080 port with a built-in CherryPy server.

## Status
To run on 8080 port:

[![Latest Version](https://img.shields.io/pypi/v/wsgidav.svg)](https://pypi.python.org/pypi/WsgiDAV/)
See the ([change log](https://github.com/mar10/wsgidav/blob/master/CHANGELOG.md)) for details.
```
cp run.sh.template run.sh
```

**Note:** Release 3.0 introduces some refactorings and breaking changes.<br>
See the ([change log](https://github.com/mar10/wsgidav/blob/master/CHANGELOG.md)) for details.
Then change CCNET_CONF_DIR and SEAFILE_CONF_DIR to your Seafile server's settings.

# Testing

## More info

* [Read The Docs](http://wsgidav.rtfd.org) for details.
* [Discussion Group](https://groups.google.com/forum/#!forum/wsgidav)
* [Stackoverflow](http://stackoverflow.com/questions/tagged/wsgidav)


## Credits

Contributors:

* WsgiDAV is a [refactored version](https://github.com/mar10/wsgidav/blob/master/doc/changelog04.md)
of [PyFileServer 0.2](https://github.com/cwho/pyfileserver),
Copyright (c) 2005 Ho Chun Wei.<br>
Chun gave his approval to change the license from LGPL to MIT-License for
this project.
* <https://github.com/mar10/wsgidav/contributors>
* Markus Majer for providing the logo (a mixture of the international
maritime signal flag for 'W (Whiskey)' and a dove.)


Any kind of feedback is very welcome!<br>
Have fun :-)<br>
Martin
- start local seafile server
- start local seahub server (While seafdav itself doesn't require seahub, we use seahub webapi as a driver for testing)
- start seafdav server
- create a test user `[email protected]` with password `test`
- Run the tests
```
export CCNET_CONF_DIR=/path/to/ccnet
export SEAFILE_CONF_DIR=/path/to/seafile-data
./ci/functest.sh test
```
83 changes: 83 additions & 0 deletions ci/functests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
set -e
if [ $# -lt "1" ]; then
echo
echo "Usage: ./functests.sh {init|runserver|test}"
echo
exit 1
fi
if [ ${TRAVIS} ] ;then
set -x
CCNET_CONF_DIR="/tmp/seafile-server/tests/conf"
SEAFILE_CONF_DIR="/tmp/seafile-server/tests/conf/seafile-data"
PYTHONPATH="/usr/local/lib/python3.6/site-packages:/tmp/seafobj:/tmp/seafile-server/tests/conf/seafile-data/:${PYTHONPATH}"
export PYTHONPATH
export CCNET_CONF_DIR
export SEAFILE_CONF_DIR

fi

function start_server() {
seaf-server -c /tmp/seafile-server/tests/conf -d /tmp/seafile-server/tests/conf/seafile-data -f -l - &
sleep 2
}

function init() {
cat > /tmp/seafile-server/tests/conf/ccnet.conf << EOF
[General]
USER_NAME = server
ID = 8e4b13b49ca79f35732d9f44a0804940d985627c
NAME = server
SERVICE_URL = http://127.0.0.1

[Network]
PORT = 10002

[Client]
PORT = 9999

[Database]
CREATE_TABLES = true
EOF
mkdir /tmp/seafile-server/tests/conf/seafile-data
touch /tmp/seafile-server/tests/conf/seafile-data/seafile.conf
touch /tmp/seafile-server/tests/conf/seafile-data/seahub_settings.py
cat > /tmp/seafile-server/tests/conf/seafile-data/seafile.conf << EOF
[database]
create_tables = true
EOF
touch ${CCNET_CONF_DIR}/seafile.ini
cat > ${CCNET_CONF_DIR}/seafile.ini << EOF
/tmp/seafile-server/tests/conf/seafile-data
EOF
start_server
python -c "from seaserv import ccnet_api as api;api.add_emailuser('[email protected]','test',0,1)"
}

function start_seafdav() {
if [ ${TRAVIS} ]; then
cd ${TRAVIS_BUILD_DIR}
python -m wsgidav.server.server_cli --host=127.0.0.1 --port=8080 --root=/ --server=gunicorn &
sleep 5
fi
}

function run_tests() {
cd seafdav_tests
py.test
}

case $1 in
"init")
init
;;
"runserver")
start_seafdav
;;
"test")
run_tests
;;
*)
echo "unknow command \"$1\""
;;
esac

30 changes: 30 additions & 0 deletions ci/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -e -x

git clone --depth=1 --branch=master git://github.com/haiwen/libevhtp /tmp/libevhtp
cd /tmp/libevhtp
cmake -DEVHTP_DISABLE_SSL=ON -DEVHTP_BUILD_SHARED=OFF .
make -j2
sudo make install
cd -

git clone --depth=1 --branch=master git://github.com/haiwen/libsearpc /tmp/libsearpc
cd /tmp/libsearpc
./autogen.sh
./configure
make -j2
sudo make install
cd -

git clone --depth=1 --branch=master git://github.com/haiwen/seafile-server /tmp/seafile-server
cd /tmp/seafile-server
./autogen.sh
./configure
make -j2
sudo make install
cd -

sudo ldconfig

git clone --depth=1 --branch=master git://github.com/haiwen/seafobj /tmp/seafobj
16 changes: 16 additions & 0 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
termcolor>=1.1.0
requests>=2.8.0
pytest>=3.3.2
backports.functools_lru_cache>=1.4
tenacity>=4.8.0
defusedxml~=0.5
Jinja2~=2.10
jsmin~=2.2
python-pam~=1.8
PyYAML~=5.1
six~=1.12
gunicorn
future
lxml
sqlalchemy
pyjson5
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ json5~=0.8.5
python-pam~=1.8
PyYAML~=5.1
six~=1.13
lxml
sqlalchemy
10 changes: 10 additions & 0 deletions run.sh.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

export CCNET_CONF_DIR=/data/data/ccnet
export SEAFILE_CONF_DIR=/data/data/seafile-data

TOP_DIR=$(python -c "import os; print os.path.dirname(os.path.realpath('$0'))")

cd "$TOP_DIR"

python -m wsgidav.server.run_server --host=0.0.0.0 --port=8080 --root=/ --server=gunicorn
Loading