msnoisedb 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- msnoisedb-0.1.4/.github/dependabot.yml +11 -0
- msnoisedb-0.1.4/.github/environment.yml +10 -0
- msnoisedb-0.1.4/.github/workflows/publish.yml +125 -0
- msnoisedb-0.1.4/.github/workflows/test_linux.yml +67 -0
- msnoisedb-0.1.4/.gitignore +29 -0
- msnoisedb-0.1.4/LICENSE.TXT +287 -0
- msnoisedb-0.1.4/PKG-INFO +155 -0
- msnoisedb-0.1.4/README.md +126 -0
- msnoisedb-0.1.4/msnoise_db/__init__.py +7 -0
- msnoisedb-0.1.4/msnoise_db/_version.py +24 -0
- msnoisedb-0.1.4/msnoise_db/cli.py +274 -0
- msnoisedb-0.1.4/msnoisedb.egg-info/PKG-INFO +155 -0
- msnoisedb-0.1.4/msnoisedb.egg-info/SOURCES.txt +17 -0
- msnoisedb-0.1.4/msnoisedb.egg-info/dependency_links.txt +1 -0
- msnoisedb-0.1.4/msnoisedb.egg-info/entry_points.txt +2 -0
- msnoisedb-0.1.4/msnoisedb.egg-info/requires.txt +1 -0
- msnoisedb-0.1.4/msnoisedb.egg-info/top_level.txt +1 -0
- msnoisedb-0.1.4/pyproject.toml +55 -0
- msnoisedb-0.1.4/setup.cfg +4 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "github-actions"
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Triggered on every published GitHub Release.
|
|
4
|
+
#
|
|
5
|
+
# Routing logic:
|
|
6
|
+
# - ALL releases → TestPyPI (alphas, betas, RCs, final)
|
|
7
|
+
# - Stable only → PyPI (tags matching vN.N.N exactly, e.g. v1.2.3)
|
|
8
|
+
#
|
|
9
|
+
# "Stable" is defined by the regex ^v[0-9]+\.[0-9]+\.[0-9]+$
|
|
10
|
+
# Pre-releases (v1.0.0a1, v1.0.0rc2, v1.0.0.post1, …) go to TestPyPI only.
|
|
11
|
+
#
|
|
12
|
+
# No API tokens required — OIDC trusted publishing handles authentication.
|
|
13
|
+
#
|
|
14
|
+
# One-time setup (already done):
|
|
15
|
+
# PyPI → Trusted Publisher: ROBelgium/msnoise-db, publish.yml, env=pypi
|
|
16
|
+
# TestPyPI→ Trusted Publisher: ROBelgium/msnoise-db, publish.yml, env=testpypi
|
|
17
|
+
# GitHub → Settings → Environments → "pypi" + "testpypi" created
|
|
18
|
+
|
|
19
|
+
on:
|
|
20
|
+
release:
|
|
21
|
+
types: [published]
|
|
22
|
+
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
# ── 1. Build sdist + wheel ────────────────────────────────────────────────
|
|
28
|
+
build:
|
|
29
|
+
name: Build distribution packages
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
|
|
32
|
+
outputs:
|
|
33
|
+
is_stable: ${{ steps.check_tag.outputs.is_stable }}
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- name: Checkout source
|
|
37
|
+
uses: actions/checkout@v4
|
|
38
|
+
with:
|
|
39
|
+
fetch-depth: 0 # setuptools-scm needs full history for version
|
|
40
|
+
|
|
41
|
+
- name: Set up Python
|
|
42
|
+
uses: actions/setup-python@v5
|
|
43
|
+
with:
|
|
44
|
+
python-version: '3.12'
|
|
45
|
+
|
|
46
|
+
- name: Install build tooling
|
|
47
|
+
run: python -m pip install --upgrade pip build twine
|
|
48
|
+
|
|
49
|
+
- name: Check whether this is a stable release tag (N.N.N)
|
|
50
|
+
id: check_tag
|
|
51
|
+
run: |
|
|
52
|
+
TAG="${GITHUB_REF_NAME}"
|
|
53
|
+
echo "Tag: $TAG"
|
|
54
|
+
if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
55
|
+
echo "is_stable=true" >> "$GITHUB_OUTPUT"
|
|
56
|
+
echo "→ stable release, will publish to PyPI"
|
|
57
|
+
else
|
|
58
|
+
echo "is_stable=false" >> "$GITHUB_OUTPUT"
|
|
59
|
+
echo "→ pre-release tag, TestPyPI only"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
- name: Build sdist and wheel
|
|
63
|
+
run: python -m build
|
|
64
|
+
|
|
65
|
+
- name: Check dist contents
|
|
66
|
+
run: |
|
|
67
|
+
twine check dist/*
|
|
68
|
+
ls -lh dist/
|
|
69
|
+
|
|
70
|
+
- name: Upload dist as artifact
|
|
71
|
+
uses: actions/upload-artifact@v4
|
|
72
|
+
with:
|
|
73
|
+
name: dist
|
|
74
|
+
path: dist/
|
|
75
|
+
if-no-files-found: error
|
|
76
|
+
|
|
77
|
+
# ── 2. Publish to TestPyPI (every release) ───────────────────────────────
|
|
78
|
+
publish-testpypi:
|
|
79
|
+
name: Publish to TestPyPI
|
|
80
|
+
needs: build
|
|
81
|
+
runs-on: ubuntu-latest
|
|
82
|
+
environment:
|
|
83
|
+
name: testpypi
|
|
84
|
+
url: https://test.pypi.org/p/msnoisedb
|
|
85
|
+
|
|
86
|
+
permissions:
|
|
87
|
+
id-token: write
|
|
88
|
+
|
|
89
|
+
steps:
|
|
90
|
+
- name: Download dist artifact
|
|
91
|
+
uses: actions/download-artifact@v4
|
|
92
|
+
with:
|
|
93
|
+
name: dist
|
|
94
|
+
path: dist/
|
|
95
|
+
|
|
96
|
+
- name: Publish to TestPyPI
|
|
97
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
98
|
+
with:
|
|
99
|
+
repository-url: https://test.pypi.org/legacy/
|
|
100
|
+
print-hash: true
|
|
101
|
+
|
|
102
|
+
# ── 3. Publish to PyPI (stable releases only: vN.N.N) ────────────────────
|
|
103
|
+
publish-pypi:
|
|
104
|
+
name: Publish to PyPI
|
|
105
|
+
needs: [build, publish-testpypi]
|
|
106
|
+
if: needs.build.outputs.is_stable == 'true'
|
|
107
|
+
runs-on: ubuntu-latest
|
|
108
|
+
environment:
|
|
109
|
+
name: pypi
|
|
110
|
+
url: https://pypi.org/p/msnoisedb
|
|
111
|
+
|
|
112
|
+
permissions:
|
|
113
|
+
id-token: write
|
|
114
|
+
|
|
115
|
+
steps:
|
|
116
|
+
- name: Download dist artifact
|
|
117
|
+
uses: actions/download-artifact@v4
|
|
118
|
+
with:
|
|
119
|
+
name: dist
|
|
120
|
+
path: dist/
|
|
121
|
+
|
|
122
|
+
- name: Publish to PyPI
|
|
123
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
124
|
+
with:
|
|
125
|
+
print-hash: true
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Test install - all OS
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '0 0 * * 1'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
run_tests:
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
if: |
|
|
13
|
+
!contains(github.event.head_commit.message, '+ONLYDOCS') &&
|
|
14
|
+
!contains(github.event.head_commit.message, '+NOFULLTEST')
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ['3.11', '3.12']
|
|
18
|
+
os: [macos-latest, ubuntu-latest, windows-latest]
|
|
19
|
+
include:
|
|
20
|
+
- os: ubuntu-latest
|
|
21
|
+
label: linux-64
|
|
22
|
+
prefix: /usr/share/miniconda3/envs/test
|
|
23
|
+
|
|
24
|
+
fail-fast: false
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- name: Get current date
|
|
28
|
+
id: date
|
|
29
|
+
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
|
|
30
|
+
|
|
31
|
+
- uses: conda-incubator/setup-miniconda@v3.1.1
|
|
32
|
+
with:
|
|
33
|
+
activate-environment: test${{ matrix.python-version }}
|
|
34
|
+
python-version: ${{ matrix.python-version }}
|
|
35
|
+
|
|
36
|
+
- uses: actions/cache@v5
|
|
37
|
+
with:
|
|
38
|
+
path: ${{ matrix.prefix }}${{ matrix.python-version }}
|
|
39
|
+
key: ${{ matrix.label }}-conda-py${{ matrix.python-version }}-${{ hashFiles('.github/environment.yml') }}-${{ steps.date.outputs.date }}-${{ env.CACHE_NUMBER }}
|
|
40
|
+
env:
|
|
41
|
+
# Increase this value to reset cache if etc/example-environment.yml has not changed
|
|
42
|
+
CACHE_NUMBER: 1
|
|
43
|
+
id: cache
|
|
44
|
+
|
|
45
|
+
- name: Update environment
|
|
46
|
+
run: conda env update -n test${{ matrix.python-version }} -f .github/environment.yml
|
|
47
|
+
if: steps.cache.outputs.cache-hit != 'true'
|
|
48
|
+
|
|
49
|
+
- name: print package info
|
|
50
|
+
shell: bash -l {0}
|
|
51
|
+
run: |
|
|
52
|
+
conda info -a
|
|
53
|
+
conda list
|
|
54
|
+
|
|
55
|
+
- name: Install MSNoise-DB
|
|
56
|
+
shell: bash -l {0}
|
|
57
|
+
run: |
|
|
58
|
+
pip install .
|
|
59
|
+
|
|
60
|
+
- name: Test suite
|
|
61
|
+
shell: bash -l {0}
|
|
62
|
+
run: |
|
|
63
|
+
msnoisedb start
|
|
64
|
+
msnoisedb create-db bubu
|
|
65
|
+
msnoisedb list-db
|
|
66
|
+
msnoisedb drop-db bubu
|
|
67
|
+
msnoisedb stop
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
*.egg-info/
|
|
5
|
+
|
|
6
|
+
# setuptools-scm generated version file (written at build time, not committed)
|
|
7
|
+
msnoise_db/_version.py
|
|
8
|
+
|
|
9
|
+
# Old version tracking file (replaced by setuptools-scm)
|
|
10
|
+
msnoise_db/RELEASE-VERSION
|
|
11
|
+
|
|
12
|
+
# Python
|
|
13
|
+
__pycache__/
|
|
14
|
+
*.py[cod]
|
|
15
|
+
*.so
|
|
16
|
+
.eggs/
|
|
17
|
+
|
|
18
|
+
# Environments
|
|
19
|
+
.env
|
|
20
|
+
.venv
|
|
21
|
+
env/
|
|
22
|
+
venv/
|
|
23
|
+
|
|
24
|
+
# IDE
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
|
|
28
|
+
# postgres data dir (created by msnoisedb start)
|
|
29
|
+
postgres_data/
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
EUROPEAN UNION PUBLIC LICENCE v. 1.2
|
|
2
|
+
EUPL © the European Union 2007, 2016
|
|
3
|
+
|
|
4
|
+
This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
|
|
5
|
+
below) which is provided under the terms of this Licence. Any use of the Work,
|
|
6
|
+
other than as authorised under this Licence is prohibited (to the extent such
|
|
7
|
+
use is covered by a right of the copyright holder of the Work).
|
|
8
|
+
|
|
9
|
+
The Work is provided under the terms of this Licence when the Licensor (as
|
|
10
|
+
defined below) has placed the following notice immediately following the
|
|
11
|
+
copyright notice for the Work:
|
|
12
|
+
|
|
13
|
+
Licensed under the EUPL
|
|
14
|
+
|
|
15
|
+
or has expressed by any other means his willingness to license under the EUPL.
|
|
16
|
+
|
|
17
|
+
1. Definitions
|
|
18
|
+
|
|
19
|
+
In this Licence, the following terms have the following meaning:
|
|
20
|
+
|
|
21
|
+
- ‘The Licence’: this Licence.
|
|
22
|
+
|
|
23
|
+
- ‘The Original Work’: the work or software distributed or communicated by the
|
|
24
|
+
Licensor under this Licence, available as Source Code and also as Executable
|
|
25
|
+
Code as the case may be.
|
|
26
|
+
|
|
27
|
+
- ‘Derivative Works’: the works or software that could be created by the
|
|
28
|
+
Licensee, based upon the Original Work or modifications thereof. This Licence
|
|
29
|
+
does not define the extent of modification or dependence on the Original Work
|
|
30
|
+
required in order to classify a work as a Derivative Work; this extent is
|
|
31
|
+
determined by copyright law applicable in the country mentioned in Article 15.
|
|
32
|
+
|
|
33
|
+
- ‘The Work’: the Original Work or its Derivative Works.
|
|
34
|
+
|
|
35
|
+
- ‘The Source Code’: the human-readable form of the Work which is the most
|
|
36
|
+
convenient for people to study and modify.
|
|
37
|
+
|
|
38
|
+
- ‘The Executable Code’: any code which has generally been compiled and which is
|
|
39
|
+
meant to be interpreted by a computer as a program.
|
|
40
|
+
|
|
41
|
+
- ‘The Licensor’: the natural or legal person that distributes or communicates
|
|
42
|
+
the Work under the Licence.
|
|
43
|
+
|
|
44
|
+
- ‘Contributor(s)’: any natural or legal person who modifies the Work under the
|
|
45
|
+
Licence, or otherwise contributes to the creation of a Derivative Work.
|
|
46
|
+
|
|
47
|
+
- ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
|
|
48
|
+
the Work under the terms of the Licence.
|
|
49
|
+
|
|
50
|
+
- ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
|
|
51
|
+
renting, distributing, communicating, transmitting, or otherwise making
|
|
52
|
+
available, online or offline, copies of the Work or providing access to its
|
|
53
|
+
essential functionalities at the disposal of any other natural or legal
|
|
54
|
+
person.
|
|
55
|
+
|
|
56
|
+
2. Scope of the rights granted by the Licence
|
|
57
|
+
|
|
58
|
+
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
|
59
|
+
sublicensable licence to do the following, for the duration of copyright vested
|
|
60
|
+
in the Original Work:
|
|
61
|
+
|
|
62
|
+
- use the Work in any circumstance and for all usage,
|
|
63
|
+
- reproduce the Work,
|
|
64
|
+
- modify the Work, and make Derivative Works based upon the Work,
|
|
65
|
+
- communicate to the public, including the right to make available or display
|
|
66
|
+
the Work or copies thereof to the public and perform publicly, as the case may
|
|
67
|
+
be, the Work,
|
|
68
|
+
- distribute the Work or copies thereof,
|
|
69
|
+
- lend and rent the Work or copies thereof,
|
|
70
|
+
- sublicense rights in the Work or copies thereof.
|
|
71
|
+
|
|
72
|
+
Those rights can be exercised on any media, supports and formats, whether now
|
|
73
|
+
known or later invented, as far as the applicable law permits so.
|
|
74
|
+
|
|
75
|
+
In the countries where moral rights apply, the Licensor waives his right to
|
|
76
|
+
exercise his moral right to the extent allowed by law in order to make effective
|
|
77
|
+
the licence of the economic rights here above listed.
|
|
78
|
+
|
|
79
|
+
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
|
|
80
|
+
any patents held by the Licensor, to the extent necessary to make use of the
|
|
81
|
+
rights granted on the Work under this Licence.
|
|
82
|
+
|
|
83
|
+
3. Communication of the Source Code
|
|
84
|
+
|
|
85
|
+
The Licensor may provide the Work either in its Source Code form, or as
|
|
86
|
+
Executable Code. If the Work is provided as Executable Code, the Licensor
|
|
87
|
+
provides in addition a machine-readable copy of the Source Code of the Work
|
|
88
|
+
along with each copy of the Work that the Licensor distributes or indicates, in
|
|
89
|
+
a notice following the copyright notice attached to the Work, a repository where
|
|
90
|
+
the Source Code is easily and freely accessible for as long as the Licensor
|
|
91
|
+
continues to distribute or communicate the Work.
|
|
92
|
+
|
|
93
|
+
4. Limitations on copyright
|
|
94
|
+
|
|
95
|
+
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
|
96
|
+
any exception or limitation to the exclusive rights of the rights owners in the
|
|
97
|
+
Work, of the exhaustion of those rights or of other applicable limitations
|
|
98
|
+
thereto.
|
|
99
|
+
|
|
100
|
+
5. Obligations of the Licensee
|
|
101
|
+
|
|
102
|
+
The grant of the rights mentioned above is subject to some restrictions and
|
|
103
|
+
obligations imposed on the Licensee. Those obligations are the following:
|
|
104
|
+
|
|
105
|
+
Attribution right: The Licensee shall keep intact all copyright, patent or
|
|
106
|
+
trademarks notices and all notices that refer to the Licence and to the
|
|
107
|
+
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
|
108
|
+
copy of the Licence with every copy of the Work he/she distributes or
|
|
109
|
+
communicates. The Licensee must cause any Derivative Work to carry prominent
|
|
110
|
+
notices stating that the Work has been modified and the date of modification.
|
|
111
|
+
|
|
112
|
+
Copyleft clause: If the Licensee distributes or communicates copies of the
|
|
113
|
+
Original Works or Derivative Works, this Distribution or Communication will be
|
|
114
|
+
done under the terms of this Licence or of a later version of this Licence
|
|
115
|
+
unless the Original Work is expressly distributed only under this version of the
|
|
116
|
+
Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
|
|
117
|
+
(becoming Licensor) cannot offer or impose any additional terms or conditions on
|
|
118
|
+
the Work or Derivative Work that alter or restrict the terms of the Licence.
|
|
119
|
+
|
|
120
|
+
Compatibility clause: If the Licensee Distributes or Communicates Derivative
|
|
121
|
+
Works or copies thereof based upon both the Work and another work licensed under
|
|
122
|
+
a Compatible Licence, this Distribution or Communication can be done under the
|
|
123
|
+
terms of this Compatible Licence. For the sake of this clause, ‘Compatible
|
|
124
|
+
Licence’ refers to the licences listed in the appendix attached to this Licence.
|
|
125
|
+
Should the Licensee's obligations under the Compatible Licence conflict with
|
|
126
|
+
his/her obligations under this Licence, the obligations of the Compatible
|
|
127
|
+
Licence shall prevail.
|
|
128
|
+
|
|
129
|
+
Provision of Source Code: When distributing or communicating copies of the Work,
|
|
130
|
+
the Licensee will provide a machine-readable copy of the Source Code or indicate
|
|
131
|
+
a repository where this Source will be easily and freely available for as long
|
|
132
|
+
as the Licensee continues to distribute or communicate the Work.
|
|
133
|
+
|
|
134
|
+
Legal Protection: This Licence does not grant permission to use the trade names,
|
|
135
|
+
trademarks, service marks, or names of the Licensor, except as required for
|
|
136
|
+
reasonable and customary use in describing the origin of the Work and
|
|
137
|
+
reproducing the content of the copyright notice.
|
|
138
|
+
|
|
139
|
+
6. Chain of Authorship
|
|
140
|
+
|
|
141
|
+
The original Licensor warrants that the copyright in the Original Work granted
|
|
142
|
+
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
|
143
|
+
power and authority to grant the Licence.
|
|
144
|
+
|
|
145
|
+
Each Contributor warrants that the copyright in the modifications he/she brings
|
|
146
|
+
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
|
147
|
+
power and authority to grant the Licence.
|
|
148
|
+
|
|
149
|
+
Each time You accept the Licence, the original Licensor and subsequent
|
|
150
|
+
Contributors grant You a licence to their contributions to the Work, under the
|
|
151
|
+
terms of this Licence.
|
|
152
|
+
|
|
153
|
+
7. Disclaimer of Warranty
|
|
154
|
+
|
|
155
|
+
The Work is a work in progress, which is continuously improved by numerous
|
|
156
|
+
Contributors. It is not a finished work and may therefore contain defects or
|
|
157
|
+
‘bugs’ inherent to this type of development.
|
|
158
|
+
|
|
159
|
+
For the above reason, the Work is provided under the Licence on an ‘as is’ basis
|
|
160
|
+
and without warranties of any kind concerning the Work, including without
|
|
161
|
+
limitation merchantability, fitness for a particular purpose, absence of defects
|
|
162
|
+
or errors, accuracy, non-infringement of intellectual property rights other than
|
|
163
|
+
copyright as stated in Article 6 of this Licence.
|
|
164
|
+
|
|
165
|
+
This disclaimer of warranty is an essential part of the Licence and a condition
|
|
166
|
+
for the grant of any rights to the Work.
|
|
167
|
+
|
|
168
|
+
8. Disclaimer of Liability
|
|
169
|
+
|
|
170
|
+
Except in the cases of wilful misconduct or damages directly caused to natural
|
|
171
|
+
persons, the Licensor will in no event be liable for any direct or indirect,
|
|
172
|
+
material or moral, damages of any kind, arising out of the Licence or of the use
|
|
173
|
+
of the Work, including without limitation, damages for loss of goodwill, work
|
|
174
|
+
stoppage, computer failure or malfunction, loss of data or any commercial
|
|
175
|
+
damage, even if the Licensor has been advised of the possibility of such damage.
|
|
176
|
+
However, the Licensor will be liable under statutory product liability laws as
|
|
177
|
+
far such laws apply to the Work.
|
|
178
|
+
|
|
179
|
+
9. Additional agreements
|
|
180
|
+
|
|
181
|
+
While distributing the Work, You may choose to conclude an additional agreement,
|
|
182
|
+
defining obligations or services consistent with this Licence. However, if
|
|
183
|
+
accepting obligations, You may act only on your own behalf and on your sole
|
|
184
|
+
responsibility, not on behalf of the original Licensor or any other Contributor,
|
|
185
|
+
and only if You agree to indemnify, defend, and hold each Contributor harmless
|
|
186
|
+
for any liability incurred by, or claims asserted against such Contributor by
|
|
187
|
+
the fact You have accepted any warranty or additional liability.
|
|
188
|
+
|
|
189
|
+
10. Acceptance of the Licence
|
|
190
|
+
|
|
191
|
+
The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
|
|
192
|
+
placed under the bottom of a window displaying the text of this Licence or by
|
|
193
|
+
affirming consent in any other similar way, in accordance with the rules of
|
|
194
|
+
applicable law. Clicking on that icon indicates your clear and irrevocable
|
|
195
|
+
acceptance of this Licence and all of its terms and conditions.
|
|
196
|
+
|
|
197
|
+
Similarly, you irrevocably accept this Licence and all of its terms and
|
|
198
|
+
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
|
199
|
+
such as the use of the Work, the creation by You of a Derivative Work or the
|
|
200
|
+
Distribution or Communication by You of the Work or copies thereof.
|
|
201
|
+
|
|
202
|
+
11. Information to the public
|
|
203
|
+
|
|
204
|
+
In case of any Distribution or Communication of the Work by means of electronic
|
|
205
|
+
communication by You (for example, by offering to download the Work from a
|
|
206
|
+
remote location) the distribution channel or media (for example, a website) must
|
|
207
|
+
at least provide to the public the information requested by the applicable law
|
|
208
|
+
regarding the Licensor, the Licence and the way it may be accessible, concluded,
|
|
209
|
+
stored and reproduced by the Licensee.
|
|
210
|
+
|
|
211
|
+
12. Termination of the Licence
|
|
212
|
+
|
|
213
|
+
The Licence and the rights granted hereunder will terminate automatically upon
|
|
214
|
+
any breach by the Licensee of the terms of the Licence.
|
|
215
|
+
|
|
216
|
+
Such a termination will not terminate the licences of any person who has
|
|
217
|
+
received the Work from the Licensee under the Licence, provided such persons
|
|
218
|
+
remain in full compliance with the Licence.
|
|
219
|
+
|
|
220
|
+
13. Miscellaneous
|
|
221
|
+
|
|
222
|
+
Without prejudice of Article 9 above, the Licence represents the complete
|
|
223
|
+
agreement between the Parties as to the Work.
|
|
224
|
+
|
|
225
|
+
If any provision of the Licence is invalid or unenforceable under applicable
|
|
226
|
+
law, this will not affect the validity or enforceability of the Licence as a
|
|
227
|
+
whole. Such provision will be construed or reformed so as necessary to make it
|
|
228
|
+
valid and enforceable.
|
|
229
|
+
|
|
230
|
+
The European Commission may publish other linguistic versions or new versions of
|
|
231
|
+
this Licence or updated versions of the Appendix, so far this is required and
|
|
232
|
+
reasonable, without reducing the scope of the rights granted by the Licence. New
|
|
233
|
+
versions of the Licence will be published with a unique version number.
|
|
234
|
+
|
|
235
|
+
All linguistic versions of this Licence, approved by the European Commission,
|
|
236
|
+
have identical value. Parties can take advantage of the linguistic version of
|
|
237
|
+
their choice.
|
|
238
|
+
|
|
239
|
+
14. Jurisdiction
|
|
240
|
+
|
|
241
|
+
Without prejudice to specific agreement between parties,
|
|
242
|
+
|
|
243
|
+
- any litigation resulting from the interpretation of this License, arising
|
|
244
|
+
between the European Union institutions, bodies, offices or agencies, as a
|
|
245
|
+
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
|
|
246
|
+
of Justice of the European Union, as laid down in article 272 of the Treaty on
|
|
247
|
+
the Functioning of the European Union,
|
|
248
|
+
|
|
249
|
+
- any litigation arising between other parties and resulting from the
|
|
250
|
+
interpretation of this License, will be subject to the exclusive jurisdiction
|
|
251
|
+
of the competent court where the Licensor resides or conducts its primary
|
|
252
|
+
business.
|
|
253
|
+
|
|
254
|
+
15. Applicable Law
|
|
255
|
+
|
|
256
|
+
Without prejudice to specific agreement between parties,
|
|
257
|
+
|
|
258
|
+
- this Licence shall be governed by the law of the European Union Member State
|
|
259
|
+
where the Licensor has his seat, resides or has his registered office,
|
|
260
|
+
|
|
261
|
+
- this licence shall be governed by Belgian law if the Licensor has no seat,
|
|
262
|
+
residence or registered office inside a European Union Member State.
|
|
263
|
+
|
|
264
|
+
Appendix
|
|
265
|
+
|
|
266
|
+
‘Compatible Licences’ according to Article 5 EUPL are:
|
|
267
|
+
|
|
268
|
+
- GNU General Public License (GPL) v. 2, v. 3
|
|
269
|
+
- GNU Affero General Public License (AGPL) v. 3
|
|
270
|
+
- Open Software License (OSL) v. 2.1, v. 3.0
|
|
271
|
+
- Eclipse Public License (EPL) v. 1.0
|
|
272
|
+
- CeCILL v. 2.0, v. 2.1
|
|
273
|
+
- Mozilla Public Licence (MPL) v. 2
|
|
274
|
+
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
|
|
275
|
+
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
|
|
276
|
+
works other than software
|
|
277
|
+
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
|
|
278
|
+
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
|
|
279
|
+
Reciprocity (LiLiQ-R+).
|
|
280
|
+
|
|
281
|
+
The European Commission may update this Appendix to later versions of the above
|
|
282
|
+
licences without producing a new version of the EUPL, as long as they provide
|
|
283
|
+
the rights granted in Article 2 of this Licence and protect the covered Source
|
|
284
|
+
Code from exclusive appropriation.
|
|
285
|
+
|
|
286
|
+
All other changes or additions to this Appendix require the production of a new
|
|
287
|
+
EUPL version.
|
msnoisedb-0.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: msnoisedb
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: The database minion for MSNoise — a self-contained, user-run PostgreSQL server
|
|
5
|
+
Author-email: Thomas Lecocq & MSNoise dev team <Thomas.Lecocq@seismology.be>
|
|
6
|
+
License: EUPL-1.1
|
|
7
|
+
Project-URL: Homepage, http://www.msnoise.org
|
|
8
|
+
Project-URL: Repository, https://github.com/ROBelgium/msnoise-db
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/ROBelgium/msnoise-db/issues
|
|
10
|
+
Keywords: noise,monitoring,seismic,velocity,change,dvv,dtt,cross-correlation,seismology,postgresql,database
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE.TXT
|
|
27
|
+
Requires-Dist: click
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# MSNoise-DB CLI Tool
|
|
31
|
+
|
|
32
|
+
This is a Python-based command-line interface (CLI) tool for managing a portable postgresql server for MSNoise.
|
|
33
|
+
|
|
34
|
+
The tool allows you to install, start, stop, create, and drop databases.
|
|
35
|
+
|
|
36
|
+
[](https://github.com/ROBelgium/msnoise-db/actions)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- Setup PostgreSQL.
|
|
42
|
+
- Start PostgreSQL server in the background (custom port by default 5099, configurable)
|
|
43
|
+
- Stop PostgreSQL server.
|
|
44
|
+
- Create a new database.
|
|
45
|
+
- Drop an existing database.
|
|
46
|
+
|
|
47
|
+
## Prerequisites
|
|
48
|
+
|
|
49
|
+
- Python 3.11 or above.
|
|
50
|
+
- `click` package: Install using `conda install -c conda-forge click`.
|
|
51
|
+
- `postgresql` package: Install using `conda install -c conda-forge postgresql`.
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
1. Install the code
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
pip install git+https://github.com/ROBelgium/msnoise-db
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
if your console doesn't have git, you can access the zip directly:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
pip install https://github.com/ROBelgium/msnoise-db/archive.master.zip
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
3. Create a new folder to store the database data
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
### Start a PostgreSQL Server (and set up if not existing)
|
|
74
|
+
|
|
75
|
+
Start the PostgreSQL server in the background.
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
msnoisedb start
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Stop PostgreSQL Server
|
|
82
|
+
|
|
83
|
+
Stop the running PostgreSQL server.
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
msnoisedb stop
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Create a New Database
|
|
90
|
+
|
|
91
|
+
Create a new database.
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
msnoisedb create-db DATABASE_NAME
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Drop an Existing Database
|
|
98
|
+
|
|
99
|
+
Drop an existing database.
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
msnoisedb drop-db DATABASE_NAME
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### List databases
|
|
106
|
+
|
|
107
|
+
Drop an existing database.
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
msnoisedb list-db
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Configuring an MSNoise project
|
|
114
|
+
|
|
115
|
+
Create a new project database
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
msnoisedb create-db test_database
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Initialise the db in msnoise:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
msnoise db init
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
Launching the init
|
|
129
|
+
Welcome to MSNoise
|
|
130
|
+
|
|
131
|
+
What database technology do you want to use?
|
|
132
|
+
[1] sqlite
|
|
133
|
+
[2] mysql
|
|
134
|
+
[3] postgresql
|
|
135
|
+
Choice: 3
|
|
136
|
+
Server: [localhost]: localhost:5099
|
|
137
|
+
Database: [msnoise]: test_database
|
|
138
|
+
Username: [msnoise]: msnoise
|
|
139
|
+
Password (not shown as you type): msnoise
|
|
140
|
+
Table prefix: []:
|
|
141
|
+
Installation Done! - Go to Configuration Step!
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Notes
|
|
146
|
+
|
|
147
|
+
- **Supported Platforms**: The tool is designed to work on Windows, Linux and MacOS platforms.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
This project is licensed under the EUPL License. See the [LICENSE](LICENSE.TXT) file for more details.
|
|
152
|
+
|
|
153
|
+
## Acknowledgements
|
|
154
|
+
|
|
155
|
+
- [Click](https://palletsprojects.com/p/click/) for creating powerful command-line interfaces.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# MSNoise-DB CLI Tool
|
|
2
|
+
|
|
3
|
+
This is a Python-based command-line interface (CLI) tool for managing a portable postgresql server for MSNoise.
|
|
4
|
+
|
|
5
|
+
The tool allows you to install, start, stop, create, and drop databases.
|
|
6
|
+
|
|
7
|
+
[](https://github.com/ROBelgium/msnoise-db/actions)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Setup PostgreSQL.
|
|
13
|
+
- Start PostgreSQL server in the background (custom port by default 5099, configurable)
|
|
14
|
+
- Stop PostgreSQL server.
|
|
15
|
+
- Create a new database.
|
|
16
|
+
- Drop an existing database.
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
- Python 3.11 or above.
|
|
21
|
+
- `click` package: Install using `conda install -c conda-forge click`.
|
|
22
|
+
- `postgresql` package: Install using `conda install -c conda-forge postgresql`.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
1. Install the code
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pip install git+https://github.com/ROBelgium/msnoise-db
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
if your console doesn't have git, you can access the zip directly:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pip install https://github.com/ROBelgium/msnoise-db/archive.master.zip
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
3. Create a new folder to store the database data
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Start a PostgreSQL Server (and set up if not existing)
|
|
45
|
+
|
|
46
|
+
Start the PostgreSQL server in the background.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
msnoisedb start
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Stop PostgreSQL Server
|
|
53
|
+
|
|
54
|
+
Stop the running PostgreSQL server.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
msnoisedb stop
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Create a New Database
|
|
61
|
+
|
|
62
|
+
Create a new database.
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
msnoisedb create-db DATABASE_NAME
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Drop an Existing Database
|
|
69
|
+
|
|
70
|
+
Drop an existing database.
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
msnoisedb drop-db DATABASE_NAME
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### List databases
|
|
77
|
+
|
|
78
|
+
Drop an existing database.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
msnoisedb list-db
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuring an MSNoise project
|
|
85
|
+
|
|
86
|
+
Create a new project database
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
msnoisedb create-db test_database
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Initialise the db in msnoise:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
msnoise db init
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
Launching the init
|
|
100
|
+
Welcome to MSNoise
|
|
101
|
+
|
|
102
|
+
What database technology do you want to use?
|
|
103
|
+
[1] sqlite
|
|
104
|
+
[2] mysql
|
|
105
|
+
[3] postgresql
|
|
106
|
+
Choice: 3
|
|
107
|
+
Server: [localhost]: localhost:5099
|
|
108
|
+
Database: [msnoise]: test_database
|
|
109
|
+
Username: [msnoise]: msnoise
|
|
110
|
+
Password (not shown as you type): msnoise
|
|
111
|
+
Table prefix: []:
|
|
112
|
+
Installation Done! - Go to Configuration Step!
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## Notes
|
|
117
|
+
|
|
118
|
+
- **Supported Platforms**: The tool is designed to work on Windows, Linux and MacOS platforms.
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
This project is licensed under the EUPL License. See the [LICENSE](LICENSE.TXT) file for more details.
|
|
123
|
+
|
|
124
|
+
## Acknowledgements
|
|
125
|
+
|
|
126
|
+
- [Click](https://palletsprojects.com/p/click/) for creating powerful command-line interfaces.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.1.4'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 4)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'gbf2f8b430'
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import click
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import time
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PostgresManager:
|
|
11
|
+
def __init__(self, data_dir=None, port=5099, host='localhost'):
|
|
12
|
+
self.data_dir = data_dir and Path(data_dir) or Path.cwd() / 'postgres_data'
|
|
13
|
+
self.port = port
|
|
14
|
+
self.host = host
|
|
15
|
+
self.data_dir.parent.mkdir(parents=True, exist_ok=True)
|
|
16
|
+
|
|
17
|
+
def init_db(self):
|
|
18
|
+
"""Initialize PostgreSQL data directory if it doesn't exist."""
|
|
19
|
+
if not (self.data_dir / 'PG_VERSION').exists():
|
|
20
|
+
click.echo(f"Initializing PostgreSQL data directory at {self.data_dir}")
|
|
21
|
+
subprocess.run(['initdb', '-D', str(self.data_dir)], check=True)
|
|
22
|
+
|
|
23
|
+
# Modify pg_hba.conf to allow password authentication
|
|
24
|
+
hba_path = self.data_dir / 'pg_hba.conf'
|
|
25
|
+
with open(hba_path, 'a') as f:
|
|
26
|
+
f.write("\n# MSNoise user authentication\n")
|
|
27
|
+
f.write("host all msnoise 127.0.0.1/32 md5\n")
|
|
28
|
+
f.write("host all msnoise ::1/128 md5\n")
|
|
29
|
+
f.write("host all msnoise localhost md5\n")
|
|
30
|
+
# Configure postgresql.conf for high number of connections
|
|
31
|
+
conf_path = self.data_dir / 'postgresql.conf'
|
|
32
|
+
click.echo("Configuring postgresql.conf for 1000 connections")
|
|
33
|
+
with open(conf_path, 'a') as f:
|
|
34
|
+
f.write("\n# MSNoise custom settings\n")
|
|
35
|
+
f.write("max_connections = 1000\n")
|
|
36
|
+
f.write("shared_buffers = 256MB\n") # Increased for many connections
|
|
37
|
+
f.write("listen_addresses = '*'\n") # Listen on all interfaces
|
|
38
|
+
|
|
39
|
+
def create_msnoise_user(self):
|
|
40
|
+
"""Create msnoise user with password if it doesn't exist."""
|
|
41
|
+
try:
|
|
42
|
+
# Create a temporary script to create user
|
|
43
|
+
create_user_sql = """
|
|
44
|
+
DO
|
|
45
|
+
$do$
|
|
46
|
+
BEGIN
|
|
47
|
+
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'msnoise') THEN
|
|
48
|
+
CREATE USER msnoise WITH PASSWORD 'msnoise';
|
|
49
|
+
END IF;
|
|
50
|
+
END
|
|
51
|
+
$do$;
|
|
52
|
+
ALTER USER msnoise CREATEDB;
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
# Use psql to execute the SQL
|
|
56
|
+
process = subprocess.Popen(
|
|
57
|
+
['psql', '-p', str(self.port), '-h', self.host, 'postgres'],
|
|
58
|
+
stdin=subprocess.PIPE,
|
|
59
|
+
stdout=subprocess.PIPE,
|
|
60
|
+
stderr=subprocess.PIPE
|
|
61
|
+
)
|
|
62
|
+
process.communicate(input=create_user_sql.encode())
|
|
63
|
+
|
|
64
|
+
if process.returncode == 0:
|
|
65
|
+
click.echo("MSNoise user created/verified successfully")
|
|
66
|
+
else:
|
|
67
|
+
click.echo("Failed to create MSNoise user", err=True)
|
|
68
|
+
|
|
69
|
+
except subprocess.CalledProcessError as e:
|
|
70
|
+
click.echo(f"Failed to create MSNoise user: {e}", err=True)
|
|
71
|
+
sys.exit(1)
|
|
72
|
+
|
|
73
|
+
def start_server(self):
|
|
74
|
+
"""Start PostgreSQL server."""
|
|
75
|
+
if self.is_server_running():
|
|
76
|
+
click.echo(f"PostgreSQL server is already running on port {self.port}")
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
self.init_db()
|
|
80
|
+
|
|
81
|
+
cmd = [
|
|
82
|
+
'pg_ctl', 'start',
|
|
83
|
+
'-D', str(self.data_dir),
|
|
84
|
+
'-o', f'-p {self.port} -h {self.host}',
|
|
85
|
+
'-l', str(self.data_dir / 'postgres.log')
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
subprocess.run(cmd, check=True)
|
|
90
|
+
time.sleep(2) # Wait for server to start
|
|
91
|
+
click.echo(f"PostgreSQL server started on {self.host}:{self.port}")
|
|
92
|
+
|
|
93
|
+
# Create msnoise user after server starts
|
|
94
|
+
self.create_msnoise_user()
|
|
95
|
+
|
|
96
|
+
except subprocess.CalledProcessError as e:
|
|
97
|
+
click.echo(f"Failed to start PostgreSQL server: {e}", err=True)
|
|
98
|
+
sys.exit(1)
|
|
99
|
+
|
|
100
|
+
def stop_server(self):
|
|
101
|
+
"""Stop PostgreSQL server."""
|
|
102
|
+
if not self.is_server_running():
|
|
103
|
+
click.echo("PostgreSQL server is not running")
|
|
104
|
+
return
|
|
105
|
+
|
|
106
|
+
cmd = ['pg_ctl', 'stop', '-D', str(self.data_dir)]
|
|
107
|
+
try:
|
|
108
|
+
subprocess.run(cmd, check=True)
|
|
109
|
+
click.echo("PostgreSQL server stopped")
|
|
110
|
+
except subprocess.CalledProcessError as e:
|
|
111
|
+
click.echo(f"Failed to stop PostgreSQL server: {e}", err=True)
|
|
112
|
+
sys.exit(1)
|
|
113
|
+
|
|
114
|
+
def create_database(self, db_name):
|
|
115
|
+
"""Create a new database."""
|
|
116
|
+
if not self.is_server_running():
|
|
117
|
+
click.echo("PostgreSQL server is not running. Please start it first.", err=True)
|
|
118
|
+
return
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
# Create database owned by msnoise user
|
|
122
|
+
subprocess.run([
|
|
123
|
+
'createdb',
|
|
124
|
+
'-p', str(self.port),
|
|
125
|
+
'-h', self.host,
|
|
126
|
+
'-O', 'msnoise',
|
|
127
|
+
db_name
|
|
128
|
+
], check=True)
|
|
129
|
+
click.echo(f"Database '{db_name}' created successfully (owned by msnoise)")
|
|
130
|
+
except subprocess.CalledProcessError as e:
|
|
131
|
+
click.echo(f"Failed to create database: {e}", err=True)
|
|
132
|
+
sys.exit(1)
|
|
133
|
+
|
|
134
|
+
def drop_database(self, db_name):
|
|
135
|
+
"""Drop an existing database."""
|
|
136
|
+
if not self.is_server_running():
|
|
137
|
+
click.echo("PostgreSQL server is not running. Please start it first.", err=True)
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
subprocess.run([
|
|
142
|
+
'dropdb',
|
|
143
|
+
'-p', str(self.port),
|
|
144
|
+
'-h', self.host,
|
|
145
|
+
db_name
|
|
146
|
+
], check=True)
|
|
147
|
+
click.echo(f"Database '{db_name}' dropped successfully")
|
|
148
|
+
except subprocess.CalledProcessError as e:
|
|
149
|
+
click.echo(f"Failed to drop database: {e}", err=True)
|
|
150
|
+
sys.exit(1)
|
|
151
|
+
|
|
152
|
+
def list_databases(self):
|
|
153
|
+
"""List all databases."""
|
|
154
|
+
if not self.is_server_running():
|
|
155
|
+
click.echo("PostgreSQL server is not running. Please start it first.", err=True)
|
|
156
|
+
return
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
result = subprocess.run(
|
|
160
|
+
['psql', '-p', str(self.port), '-h', self.host,
|
|
161
|
+
'-U', 'msnoise', '-l', ],
|
|
162
|
+
check=True,
|
|
163
|
+
capture_output=True,
|
|
164
|
+
text=True,
|
|
165
|
+
env={**os.environ, 'PGPASSWORD': 'msnoise'}
|
|
166
|
+
)
|
|
167
|
+
click.echo("Available databases:")
|
|
168
|
+
click.echo(result.stdout)
|
|
169
|
+
except subprocess.CalledProcessError as e:
|
|
170
|
+
click.echo(f"Failed to list databases: {e}", err=True)
|
|
171
|
+
if e.stderr:
|
|
172
|
+
click.echo(e.stderr, err=True)
|
|
173
|
+
sys.exit(1)
|
|
174
|
+
|
|
175
|
+
def is_server_running(self):
|
|
176
|
+
"""Check if PostgreSQL server is running."""
|
|
177
|
+
try:
|
|
178
|
+
subprocess.run(
|
|
179
|
+
['pg_ctl', 'status', '-D', str(self.data_dir)],
|
|
180
|
+
check=True,
|
|
181
|
+
capture_output=True
|
|
182
|
+
)
|
|
183
|
+
return True
|
|
184
|
+
except subprocess.CalledProcessError:
|
|
185
|
+
return False
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# Shared options for all commands
|
|
189
|
+
def common_options(f):
|
|
190
|
+
f = click.option('--port', default=5099, help='Port number (default: 5099)')(f)
|
|
191
|
+
f = click.option('--host', default='localhost', help='Listen address (default: localhost)')(f)
|
|
192
|
+
f = click.option('--data-dir', type=click.Path(), help='Custom data directory path')(f)
|
|
193
|
+
return f
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@click.group()
|
|
197
|
+
def cli():
|
|
198
|
+
"""PostgreSQL Server Management CLI for MSNoise
|
|
199
|
+
|
|
200
|
+
This CLI tool manages a PostgreSQL server instance configured for MSNoise,
|
|
201
|
+
with automatic user creation (msnoise:msnoise) and appropriate permissions.
|
|
202
|
+
"""
|
|
203
|
+
pass
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@cli.command()
|
|
207
|
+
@common_options
|
|
208
|
+
def start(port, host, data_dir):
|
|
209
|
+
"""Start PostgreSQL server with MSNoise user configuration"""
|
|
210
|
+
pg_manager = PostgresManager(
|
|
211
|
+
data_dir=data_dir and Path(data_dir),
|
|
212
|
+
port=port,
|
|
213
|
+
host=host
|
|
214
|
+
)
|
|
215
|
+
pg_manager.start_server()
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@cli.command()
|
|
219
|
+
@common_options
|
|
220
|
+
def stop(port, host, data_dir):
|
|
221
|
+
"""Stop PostgreSQL server"""
|
|
222
|
+
pg_manager = PostgresManager(
|
|
223
|
+
data_dir=data_dir and Path(data_dir),
|
|
224
|
+
port=port,
|
|
225
|
+
host=host
|
|
226
|
+
)
|
|
227
|
+
pg_manager.stop_server()
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@cli.command()
|
|
231
|
+
@click.argument('db_name')
|
|
232
|
+
@common_options
|
|
233
|
+
def create_db(db_name, port, host, data_dir):
|
|
234
|
+
"""Create a new database owned by msnoise user"""
|
|
235
|
+
pg_manager = PostgresManager(
|
|
236
|
+
data_dir=data_dir and Path(data_dir),
|
|
237
|
+
port=port,
|
|
238
|
+
host=host
|
|
239
|
+
)
|
|
240
|
+
pg_manager.create_database(db_name)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@cli.command()
|
|
244
|
+
@common_options
|
|
245
|
+
def list_db(port, host, data_dir):
|
|
246
|
+
"""List all databases"""
|
|
247
|
+
pg_manager = PostgresManager(
|
|
248
|
+
data_dir=data_dir and Path(data_dir),
|
|
249
|
+
port=port,
|
|
250
|
+
host=host
|
|
251
|
+
)
|
|
252
|
+
pg_manager.list_databases()
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@cli.command()
|
|
256
|
+
@click.argument('db_name')
|
|
257
|
+
@common_options
|
|
258
|
+
def drop_db(db_name, port, host, data_dir):
|
|
259
|
+
"""Drop an existing database"""
|
|
260
|
+
pg_manager = PostgresManager(
|
|
261
|
+
data_dir=data_dir and Path(data_dir),
|
|
262
|
+
port=port,
|
|
263
|
+
host=host
|
|
264
|
+
)
|
|
265
|
+
pg_manager.drop_database(db_name)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def run():
|
|
270
|
+
cli(obj={})
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
if __name__ == '__main__':
|
|
274
|
+
run()
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: msnoisedb
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: The database minion for MSNoise — a self-contained, user-run PostgreSQL server
|
|
5
|
+
Author-email: Thomas Lecocq & MSNoise dev team <Thomas.Lecocq@seismology.be>
|
|
6
|
+
License: EUPL-1.1
|
|
7
|
+
Project-URL: Homepage, http://www.msnoise.org
|
|
8
|
+
Project-URL: Repository, https://github.com/ROBelgium/msnoise-db
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/ROBelgium/msnoise-db/issues
|
|
10
|
+
Keywords: noise,monitoring,seismic,velocity,change,dvv,dtt,cross-correlation,seismology,postgresql,database
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE.TXT
|
|
27
|
+
Requires-Dist: click
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# MSNoise-DB CLI Tool
|
|
31
|
+
|
|
32
|
+
This is a Python-based command-line interface (CLI) tool for managing a portable postgresql server for MSNoise.
|
|
33
|
+
|
|
34
|
+
The tool allows you to install, start, stop, create, and drop databases.
|
|
35
|
+
|
|
36
|
+
[](https://github.com/ROBelgium/msnoise-db/actions)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- Setup PostgreSQL.
|
|
42
|
+
- Start PostgreSQL server in the background (custom port by default 5099, configurable)
|
|
43
|
+
- Stop PostgreSQL server.
|
|
44
|
+
- Create a new database.
|
|
45
|
+
- Drop an existing database.
|
|
46
|
+
|
|
47
|
+
## Prerequisites
|
|
48
|
+
|
|
49
|
+
- Python 3.11 or above.
|
|
50
|
+
- `click` package: Install using `conda install -c conda-forge click`.
|
|
51
|
+
- `postgresql` package: Install using `conda install -c conda-forge postgresql`.
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
1. Install the code
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
pip install git+https://github.com/ROBelgium/msnoise-db
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
if your console doesn't have git, you can access the zip directly:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
pip install https://github.com/ROBelgium/msnoise-db/archive.master.zip
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
3. Create a new folder to store the database data
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
### Start a PostgreSQL Server (and set up if not existing)
|
|
74
|
+
|
|
75
|
+
Start the PostgreSQL server in the background.
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
msnoisedb start
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Stop PostgreSQL Server
|
|
82
|
+
|
|
83
|
+
Stop the running PostgreSQL server.
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
msnoisedb stop
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Create a New Database
|
|
90
|
+
|
|
91
|
+
Create a new database.
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
msnoisedb create-db DATABASE_NAME
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Drop an Existing Database
|
|
98
|
+
|
|
99
|
+
Drop an existing database.
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
msnoisedb drop-db DATABASE_NAME
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### List databases
|
|
106
|
+
|
|
107
|
+
Drop an existing database.
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
msnoisedb list-db
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Configuring an MSNoise project
|
|
114
|
+
|
|
115
|
+
Create a new project database
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
msnoisedb create-db test_database
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Initialise the db in msnoise:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
msnoise db init
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
Launching the init
|
|
129
|
+
Welcome to MSNoise
|
|
130
|
+
|
|
131
|
+
What database technology do you want to use?
|
|
132
|
+
[1] sqlite
|
|
133
|
+
[2] mysql
|
|
134
|
+
[3] postgresql
|
|
135
|
+
Choice: 3
|
|
136
|
+
Server: [localhost]: localhost:5099
|
|
137
|
+
Database: [msnoise]: test_database
|
|
138
|
+
Username: [msnoise]: msnoise
|
|
139
|
+
Password (not shown as you type): msnoise
|
|
140
|
+
Table prefix: []:
|
|
141
|
+
Installation Done! - Go to Configuration Step!
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Notes
|
|
146
|
+
|
|
147
|
+
- **Supported Platforms**: The tool is designed to work on Windows, Linux and MacOS platforms.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
This project is licensed under the EUPL License. See the [LICENSE](LICENSE.TXT) file for more details.
|
|
152
|
+
|
|
153
|
+
## Acknowledgements
|
|
154
|
+
|
|
155
|
+
- [Click](https://palletsprojects.com/p/click/) for creating powerful command-line interfaces.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
LICENSE.TXT
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
.github/dependabot.yml
|
|
6
|
+
.github/environment.yml
|
|
7
|
+
.github/workflows/publish.yml
|
|
8
|
+
.github/workflows/test_linux.yml
|
|
9
|
+
msnoise_db/__init__.py
|
|
10
|
+
msnoise_db/_version.py
|
|
11
|
+
msnoise_db/cli.py
|
|
12
|
+
msnoisedb.egg-info/PKG-INFO
|
|
13
|
+
msnoisedb.egg-info/SOURCES.txt
|
|
14
|
+
msnoisedb.egg-info/dependency_links.txt
|
|
15
|
+
msnoisedb.egg-info/entry_points.txt
|
|
16
|
+
msnoisedb.egg-info/requires.txt
|
|
17
|
+
msnoisedb.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
click
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
msnoise_db
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "setuptools-scm>=8"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "msnoisedb"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "The database minion for MSNoise — a self-contained, user-run PostgreSQL server"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "EUPL-1.1" }
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Thomas Lecocq & MSNoise dev team", email = "Thomas.Lecocq@seismology.be" }
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
keywords = [
|
|
16
|
+
"noise", "monitoring", "seismic", "velocity", "change",
|
|
17
|
+
"dvv", "dtt", "cross-correlation", "seismology", "postgresql", "database"
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 5 - Production/Stable",
|
|
21
|
+
"Environment :: Console",
|
|
22
|
+
"Intended Audience :: Science/Research",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Programming Language :: Python",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3.10",
|
|
28
|
+
"Programming Language :: Python :: 3.11",
|
|
29
|
+
"Programming Language :: Python :: 3.12",
|
|
30
|
+
"Programming Language :: Python :: 3.13",
|
|
31
|
+
"Topic :: Scientific/Engineering",
|
|
32
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
33
|
+
]
|
|
34
|
+
dependencies = [
|
|
35
|
+
"click",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "http://www.msnoise.org"
|
|
40
|
+
Repository = "https://github.com/ROBelgium/msnoise-db"
|
|
41
|
+
"Bug Tracker" = "https://github.com/ROBelgium/msnoise-db/issues"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
msnoisedb = "msnoise_db.cli:run"
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["."]
|
|
48
|
+
include = ["msnoise_db*"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools_scm]
|
|
51
|
+
# Writes the version into msnoise_db/_version.py at build time.
|
|
52
|
+
# The installed package reads it from there via importlib.metadata.
|
|
53
|
+
write_to = "msnoise_db/_version.py"
|
|
54
|
+
version_scheme = "guess-next-dev"
|
|
55
|
+
local_scheme = "no-local-version" # keeps TestPyPI uploads clean (no +local suffix)
|