ufload3 1.0__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.
- ufload3-1.0/LICENSE +21 -0
- ufload3-1.0/PKG-INFO +128 -0
- ufload3-1.0/README.md +113 -0
- ufload3-1.0/pyproject.toml +24 -0
- ufload3-1.0/setup.cfg +4 -0
- ufload3-1.0/ufload3/__init__.py +11 -0
- ufload3-1.0/ufload3/cli/__init__.py +0 -0
- ufload3-1.0/ufload3/cli/main.py +897 -0
- ufload3-1.0/ufload3/cli/test_main.py +14 -0
- ufload3-1.0/ufload3/cloud.py +288 -0
- ufload3-1.0/ufload3/db.py +931 -0
- ufload3-1.0/ufload3/test_cloud.py +8 -0
- ufload3-1.0/ufload3/test_db.py +22 -0
- ufload3-1.0/ufload3/webdav.py +261 -0
- ufload3-1.0/ufload3.egg-info/PKG-INFO +128 -0
- ufload3-1.0/ufload3.egg-info/SOURCES.txt +18 -0
- ufload3-1.0/ufload3.egg-info/dependency_links.txt +1 -0
- ufload3-1.0/ufload3.egg-info/entry_points.txt +2 -0
- ufload3-1.0/ufload3.egg-info/requires.txt +1 -0
- ufload3-1.0/ufload3.egg-info/top_level.txt +1 -0
ufload3-1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Médecins Sans Frontières (MSF)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ufload3-1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ufload3
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: UniField python3 loader
|
|
5
|
+
Author: MSF
|
|
6
|
+
Project-URL: Homepage, https://github.com/Unifield/ufload3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: Office365-REST-Python-Client==2.3.3
|
|
15
|
+
|
|
16
|
+
# ufload3
|
|
17
|
+
The Unifield Loader
|
|
18
|
+
|
|
19
|
+
[](https://travis-ci.org/Unifield/ufload3)
|
|
20
|
+
|
|
21
|
+
ufload3 is targeted at people who load dumps from live Unifield
|
|
22
|
+
instances into non-production testing/staging/training
|
|
23
|
+
instances. ufload3 will never leave a non-production database in a
|
|
24
|
+
production configuration (it will stomp production passwords and
|
|
25
|
+
disconnect from the live sync server).
|
|
26
|
+
|
|
27
|
+
ufload3 is 100% Python, and has been tested on Linux and Windows.
|
|
28
|
+
|
|
29
|
+
ufload3 can iterate over all the backups in a directory on ownCloud,
|
|
30
|
+
and restore the latest backup for each instance. You can limit the
|
|
31
|
+
list of instances to be restored.
|
|
32
|
+
|
|
33
|
+
ufload3 can make coffee for you in the morning, and then do your dishes.
|
|
34
|
+
|
|
35
|
+
## Installing on Windows
|
|
36
|
+
|
|
37
|
+
1. Install Python 3.10 from here: https://www.python.org/downloads/windows/
|
|
38
|
+
2. Add this directory to your PATH, separated from previous ones
|
|
39
|
+
by a semi-colon:
|
|
40
|
+
* ;C:\Python27;C:\Python27\Scripts
|
|
41
|
+
or with cmd line in windows:
|
|
42
|
+
```SETX /M PATH "%PATH%;C:\Python3;C:\Python3\Scripts"```
|
|
43
|
+
3. In a new CMD.EXE window, type: ```pip install --upgrade ufload3```
|
|
44
|
+
4. Run ```ufload3 -h``` to get help.
|
|
45
|
+
5. Use Notepad to create a config file. Put the file in the same place CMD.EXE starts from, for example ```d:\Users\jae```. The file should be named ufload3.txt. Be careful: notepad.exe will create a file called ufload3.txt.txt by default. To avoid this, use "Save as..." and do not include .txt. Put the following into it:
|
|
46
|
+
```
|
|
47
|
+
[owncloud]
|
|
48
|
+
user=username
|
|
49
|
+
pw=password for OneDrive backup
|
|
50
|
+
oc=your OC:OCA/OCB/OCG/OCP
|
|
51
|
+
|
|
52
|
+
[postgres]
|
|
53
|
+
db_user=openpg
|
|
54
|
+
db_pw=yourdatabasepassword
|
|
55
|
+
|
|
56
|
+
[restore]
|
|
57
|
+
#adminuser=admin
|
|
58
|
+
#adminpw=youradminpassword
|
|
59
|
+
#userspw=youruserpassword
|
|
60
|
+
workingdir=D:\
|
|
61
|
+
|
|
62
|
+
[logs]
|
|
63
|
+
local=D:\logs
|
|
64
|
+
```
|
|
65
|
+
6. Use "dir" to confirm that the file is where you expect it to be, and is named "ufload3.txt" and not "ufload3.txt.txt".
|
|
66
|
+
|
|
67
|
+
For each line, put the right thing. If you do not want to put your
|
|
68
|
+
password in the file, you can add the ```-pw``` flag to any command,
|
|
69
|
+
after ```ufload3.exe```.
|
|
70
|
+
|
|
71
|
+
## Installing on Linux
|
|
72
|
+
|
|
73
|
+
```sudo pip install --upgrade ufload3```
|
|
74
|
+
|
|
75
|
+
The config file is in $HOME/.ufload3
|
|
76
|
+
|
|
77
|
+
## Upgrading
|
|
78
|
+
|
|
79
|
+
Use the same command as you used to install it: ```pip install --upgrade ufload3```
|
|
80
|
+
|
|
81
|
+
## Example Commands
|
|
82
|
+
|
|
83
|
+
To see a list of all backup files for an instance: ```ufload3 ls -i OCG_HQ```
|
|
84
|
+
|
|
85
|
+
For all instances, remove the ```-i``` flag.
|
|
86
|
+
|
|
87
|
+
To load all of the instances from OneDrive: ```ufload3 restore```
|
|
88
|
+
|
|
89
|
+
To load the OCG_HQ instance and all the OCG_NE1 instances from OneDrive: ```ufload3 restore -i OCG_HQ -i OCG_NE1```
|
|
90
|
+
|
|
91
|
+
To load the OCG_HQ and OCG_NE1 instances from OneDrive and load a sync server: ```ufload3 restore -i OCG_HQ -i OCG_NE1 -load-sync-server```
|
|
92
|
+
|
|
93
|
+
## Scheduling ufload3 in Windows
|
|
94
|
+
|
|
95
|
+
You can use the Windows Task Scheduler to run ufload3 in order to update a
|
|
96
|
+
sandbox environment every night.
|
|
97
|
+
|
|
98
|
+
Use the remote option in the [logs] section to arrange for remote logging.
|
|
99
|
+
|
|
100
|
+
Use a command like this to schedule it once a day: ```schtasks /create /F /TN Ufload /SC DAILY /st 20:00 /tr "cmd.exe /C start /min cmd.exe /C C:\python27\Scripts\ufload3 restore -load-sync-server"```
|
|
101
|
+
|
|
102
|
+
Or this to make it run every hour: ```schtasks /create /F /TN Ufload /SC DAILY /RI 60 /st 00:00 /du 24:00 /tr "cmd.exe /C start /min cmd.exe /C C:\python27\Scripts\ufload3 restore -load-sync-server"```
|
|
103
|
+
|
|
104
|
+
## Integrating other tools into ufload3
|
|
105
|
+
|
|
106
|
+
Ufload's ```restore``` command has a ```-notify``` flag which will
|
|
107
|
+
call a program each time a database is sucessfully loaded. The program
|
|
108
|
+
receives the name of the newly loaded database as it's first argument.
|
|
109
|
+
|
|
110
|
+
For instance, the following script sends e-mail when a backup file is
|
|
111
|
+
older than expected:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
#!/bin/sh
|
|
115
|
+
|
|
116
|
+
db=$1
|
|
117
|
+
|
|
118
|
+
# Convert OCG_NE1_COO_20161210_2102 into 20161210
|
|
119
|
+
d=`echo $db | perl -F_ -lane 'print $F[-2]'`
|
|
120
|
+
limit=`date --date='5 days ago' +%Y%m%d`
|
|
121
|
+
|
|
122
|
+
if [ "$d" -lt "$limit" ]; then
|
|
123
|
+
echo "Database $db is too old." | mail user@example.org
|
|
124
|
+
fi
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
If it was loaded in ```/bin/notify-old-db```, then
|
|
128
|
+
```ufload3 restore -notify /bin/notify-old-db``` will run the script.
|
ufload3-1.0/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# ufload3
|
|
2
|
+
The Unifield Loader
|
|
3
|
+
|
|
4
|
+
[](https://travis-ci.org/Unifield/ufload3)
|
|
5
|
+
|
|
6
|
+
ufload3 is targeted at people who load dumps from live Unifield
|
|
7
|
+
instances into non-production testing/staging/training
|
|
8
|
+
instances. ufload3 will never leave a non-production database in a
|
|
9
|
+
production configuration (it will stomp production passwords and
|
|
10
|
+
disconnect from the live sync server).
|
|
11
|
+
|
|
12
|
+
ufload3 is 100% Python, and has been tested on Linux and Windows.
|
|
13
|
+
|
|
14
|
+
ufload3 can iterate over all the backups in a directory on ownCloud,
|
|
15
|
+
and restore the latest backup for each instance. You can limit the
|
|
16
|
+
list of instances to be restored.
|
|
17
|
+
|
|
18
|
+
ufload3 can make coffee for you in the morning, and then do your dishes.
|
|
19
|
+
|
|
20
|
+
## Installing on Windows
|
|
21
|
+
|
|
22
|
+
1. Install Python 3.10 from here: https://www.python.org/downloads/windows/
|
|
23
|
+
2. Add this directory to your PATH, separated from previous ones
|
|
24
|
+
by a semi-colon:
|
|
25
|
+
* ;C:\Python27;C:\Python27\Scripts
|
|
26
|
+
or with cmd line in windows:
|
|
27
|
+
```SETX /M PATH "%PATH%;C:\Python3;C:\Python3\Scripts"```
|
|
28
|
+
3. In a new CMD.EXE window, type: ```pip install --upgrade ufload3```
|
|
29
|
+
4. Run ```ufload3 -h``` to get help.
|
|
30
|
+
5. Use Notepad to create a config file. Put the file in the same place CMD.EXE starts from, for example ```d:\Users\jae```. The file should be named ufload3.txt. Be careful: notepad.exe will create a file called ufload3.txt.txt by default. To avoid this, use "Save as..." and do not include .txt. Put the following into it:
|
|
31
|
+
```
|
|
32
|
+
[owncloud]
|
|
33
|
+
user=username
|
|
34
|
+
pw=password for OneDrive backup
|
|
35
|
+
oc=your OC:OCA/OCB/OCG/OCP
|
|
36
|
+
|
|
37
|
+
[postgres]
|
|
38
|
+
db_user=openpg
|
|
39
|
+
db_pw=yourdatabasepassword
|
|
40
|
+
|
|
41
|
+
[restore]
|
|
42
|
+
#adminuser=admin
|
|
43
|
+
#adminpw=youradminpassword
|
|
44
|
+
#userspw=youruserpassword
|
|
45
|
+
workingdir=D:\
|
|
46
|
+
|
|
47
|
+
[logs]
|
|
48
|
+
local=D:\logs
|
|
49
|
+
```
|
|
50
|
+
6. Use "dir" to confirm that the file is where you expect it to be, and is named "ufload3.txt" and not "ufload3.txt.txt".
|
|
51
|
+
|
|
52
|
+
For each line, put the right thing. If you do not want to put your
|
|
53
|
+
password in the file, you can add the ```-pw``` flag to any command,
|
|
54
|
+
after ```ufload3.exe```.
|
|
55
|
+
|
|
56
|
+
## Installing on Linux
|
|
57
|
+
|
|
58
|
+
```sudo pip install --upgrade ufload3```
|
|
59
|
+
|
|
60
|
+
The config file is in $HOME/.ufload3
|
|
61
|
+
|
|
62
|
+
## Upgrading
|
|
63
|
+
|
|
64
|
+
Use the same command as you used to install it: ```pip install --upgrade ufload3```
|
|
65
|
+
|
|
66
|
+
## Example Commands
|
|
67
|
+
|
|
68
|
+
To see a list of all backup files for an instance: ```ufload3 ls -i OCG_HQ```
|
|
69
|
+
|
|
70
|
+
For all instances, remove the ```-i``` flag.
|
|
71
|
+
|
|
72
|
+
To load all of the instances from OneDrive: ```ufload3 restore```
|
|
73
|
+
|
|
74
|
+
To load the OCG_HQ instance and all the OCG_NE1 instances from OneDrive: ```ufload3 restore -i OCG_HQ -i OCG_NE1```
|
|
75
|
+
|
|
76
|
+
To load the OCG_HQ and OCG_NE1 instances from OneDrive and load a sync server: ```ufload3 restore -i OCG_HQ -i OCG_NE1 -load-sync-server```
|
|
77
|
+
|
|
78
|
+
## Scheduling ufload3 in Windows
|
|
79
|
+
|
|
80
|
+
You can use the Windows Task Scheduler to run ufload3 in order to update a
|
|
81
|
+
sandbox environment every night.
|
|
82
|
+
|
|
83
|
+
Use the remote option in the [logs] section to arrange for remote logging.
|
|
84
|
+
|
|
85
|
+
Use a command like this to schedule it once a day: ```schtasks /create /F /TN Ufload /SC DAILY /st 20:00 /tr "cmd.exe /C start /min cmd.exe /C C:\python27\Scripts\ufload3 restore -load-sync-server"```
|
|
86
|
+
|
|
87
|
+
Or this to make it run every hour: ```schtasks /create /F /TN Ufload /SC DAILY /RI 60 /st 00:00 /du 24:00 /tr "cmd.exe /C start /min cmd.exe /C C:\python27\Scripts\ufload3 restore -load-sync-server"```
|
|
88
|
+
|
|
89
|
+
## Integrating other tools into ufload3
|
|
90
|
+
|
|
91
|
+
Ufload's ```restore``` command has a ```-notify``` flag which will
|
|
92
|
+
call a program each time a database is sucessfully loaded. The program
|
|
93
|
+
receives the name of the newly loaded database as it's first argument.
|
|
94
|
+
|
|
95
|
+
For instance, the following script sends e-mail when a backup file is
|
|
96
|
+
older than expected:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
#!/bin/sh
|
|
100
|
+
|
|
101
|
+
db=$1
|
|
102
|
+
|
|
103
|
+
# Convert OCG_NE1_COO_20161210_2102 into 20161210
|
|
104
|
+
d=`echo $db | perl -F_ -lane 'print $F[-2]'`
|
|
105
|
+
limit=`date --date='5 days ago' +%Y%m%d`
|
|
106
|
+
|
|
107
|
+
if [ "$d" -lt "$limit" ]; then
|
|
108
|
+
echo "Database $db is too old." | mail user@example.org
|
|
109
|
+
fi
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
If it was loaded in ```/bin/notify-old-db```, then
|
|
113
|
+
```ufload3 restore -notify /bin/notify-old-db``` will run the script.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ufload3"
|
|
3
|
+
version = "1.0"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="MSF" },
|
|
6
|
+
]
|
|
7
|
+
description = "UniField python3 loader"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"Office365-REST-Python-Client==2.3.3",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/Unifield/ufload3"
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
ufload3 = "ufload3.cli.main:main"
|
ufload3-1.0/setup.cfg
ADDED
|
File without changes
|