-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
src/wordpress/models.py
Outdated
def __init__(self, openshift_env, wp_site_url, wp_default_site_title=None): | ||
def __init__(self, openshift_env, wp_site_id, wp_site_url, wp_default_site_title=None): | ||
|
||
self. wp_site_id = wp_site_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y'a un espace de trop là non ?
src/wordpress/config.py
Outdated
@@ -65,8 +65,8 @@ def keep_wp_sites(dir_name): | |||
yield WPResult(wp_config.wp_site.path, "KO", "", "", "", "", "") | |||
|
|||
def run_wp_cli(self, command): | |||
cmd = "wp {} --path='{}'".format(command, self.wp_site.path) | |||
return Utils.run_command(cmd) | |||
WPUtils.run_wp_cli(command, self.wp_site.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faudrait faire un return WPUtils.run_wp_cli(command, sefl.wp_site_path)
Parce que là, tu exécutes 2x la commande, une fois en l'appelant via WPUtils.run_wp_cli
et une fois via return Utils.run_command
. Quoique le 2e appel sera probablement foireux car il n'y a pas de notion de "path".
src/wordpress/backup.py
Outdated
else: | ||
self.dir_name = self.wp_site.folder.split("/")[-1] | ||
|
||
# Create a backup folder data/backups/wp_site_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Détail mais en lisant le commentaire, j'ai compris que la commande créait le dossier de backup... alors que c'est juste le chemin jusqu'à celui-ci qui est généré. La création du dossier en elle-même est faite plus tard
Oui c'est corrigé !
2017-10-30 8:19 GMT+01:00 LuluTchab <notifications@github.com>:
… ***@***.**** commented on this pull request.
------------------------------
In src/wordpress/models.py
<#57 (comment)>:
> @@ -25,7 +33,9 @@ class WPSite:
DEFAULT_TITLE = "New WordPress"
WP_VERSION = Utils.get_mandatory_env(key="WP_VERSION")
- def __init__(self, openshift_env, wp_site_url, wp_default_site_title=None):
+ def __init__(self, openshift_env, wp_site_id, wp_site_url, wp_default_site_title=None):
+
+ self. wp_site_id = wp_site_id
Y'a un espace de trop là non ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#57 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AExAaBC-MijbhmalIlAshPQPizE76I6zks5sxXhpgaJpZM4QKMxg>
.
|
Oui c'est bien
return WPUtils.run_wp_cli(command, self.wp_site.path)
Tes 2 remarques sont sur une partie du code en dehors de backup.py et
donc pas testé ... et cela se voit !
J'ai aussi mis en coup de PEP8
2017-10-30 8:21 GMT+01:00 LuluTchab <notifications@github.com>:
… ***@***.**** commented on this pull request.
------------------------------
In src/wordpress/config.py
<#57 (comment)>:
> @@ -65,8 +65,8 @@ def keep_wp_sites(dir_name):
yield WPResult(wp_config.wp_site.path, "KO", "", "", "", "", "")
def run_wp_cli(self, command):
- cmd = "wp {} --path='{}'".format(command, self.wp_site.path)
- return Utils.run_command(cmd)
+ WPUtils.run_wp_cli(command, self.wp_site.path)
Faudrait faire un return WPUtils.run_wp_cli(command, sefl.wp_site_path)
Parce que là, tu exécutes 2x la commande, une fois en l'appelant via
WPUtils.run_wp_cli et une fois via return Utils.run_command. Quoique le
2e appel sera probablement foireux car il n'y a pas de notion de "path".
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#57 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AExAaGDcqTVX5fjXUk3zkeOgrhCau_3Nks5sxXjogaJpZM4QKMxg>
.
|
Donc j'ai corrigé, tu peux faire un pull
2017-10-30 8:53 GMT+01:00 Grégory Charmier <gregory.charmier@gmail.com>:
… Oui c'est bien
return WPUtils.run_wp_cli(command, self.wp_site.path)
Tes 2 remarques sont sur une partie du code en dehors de backup.py et donc pas testé ... et cela se voit !
J'ai aussi mis en coup de PEP8
2017-10-30 8:21 GMT+01:00 LuluTchab ***@***.***>:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/wordpress/config.py
> <#57 (comment)>
> :
>
> > @@ -65,8 +65,8 @@ def keep_wp_sites(dir_name):
> yield WPResult(wp_config.wp_site.path, "KO", "", "", "", "", "")
>
> def run_wp_cli(self, command):
> - cmd = "wp {} --path='{}'".format(command, self.wp_site.path)
> - return Utils.run_command(cmd)
> + WPUtils.run_wp_cli(command, self.wp_site.path)
>
> Faudrait faire un return WPUtils.run_wp_cli(command, sefl.wp_site_path)
>
> Parce que là, tu exécutes 2x la commande, une fois en l'appelant via
> WPUtils.run_wp_cli et une fois via return Utils.run_command. Quoique le
> 2e appel sera probablement foireux car il n'y a pas de notion de "path".
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#57 (review)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AExAaGDcqTVX5fjXUk3zkeOgrhCau_3Nks5sxXjogaJpZM4QKMxg>
> .
>
|
Si c'est pas clair n'hésites pas à modifier !
Merci pour ta relecture !
2017-10-30 8:22 GMT+01:00 LuluTchab <notifications@github.com>:
… ***@***.**** commented on this pull request.
------------------------------
In src/wordpress/backup.py
<#57 (comment)>:
> +
+ BACKUP_ROOT_DIR = "../data/backups/"
+ REGEX_FULL_NUMBER = ".+full([0-9]+)\.tar$"
+ REGEX_INC_NUMBER = ".+full{}_inc([0-9]+)\.tar$"
+
+ def __init__(self, wp_site, backup_type):
+
+ self.wp_site = wp_site
+ self.type = backup_type
+
+ if not self.wp_site.folder:
+ self.dir_name = "localhost"
+ else:
+ self.dir_name = self.wp_site.folder.split("/")[-1]
+
+ # Create a backup folder data/backups/wp_site_id
Détail mais en lisant le commentaire, j'ai compris que la commande créait
le dossier de backup... alors que c'est juste le chemin jusqu'à celui-ci
qui est généré. La création du dossier en elle-même est faite plus tard
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#57 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AExAaCAHVpsIwnfjdLz8rgJxKruFfbUaks5sxXkwgaJpZM4QKMxg>
.
|
J'ai regardé pourquoi les checks Travis ne passaient pas et y'a encore plein de choses à modifier pour que "wp_site_id" soit pris en compte partout... y compris modifier les tests Travis. |
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
=========================================
+ Coverage 82.88% 83.59% +0.7%
=========================================
Files 20 21 +1
Lines 1221 1359 +138
=========================================
+ Hits 1012 1136 +124
- Misses 209 223 +14
Continue to review full report at Codecov.
|
Tests Travis fonctionnels après modifications 😀 |
b4f1152
to
675dd3c
Compare
Après discussion avec @lboatto et @LuluTchab , j'ai "annulé" les 5 derniers commits qui introduisaient le
|
src/jahia2wp.py
Outdated
jahia2wp.py admins <wp_env> <wp_site_id> <wp_url> [--debug | --quiet] | ||
jahia2wp.py check-one <wp_env> <wp_site_id> <wp_url> [--debug | --quiet] [DEPRECATED] | ||
jahia2wp.py clean-one <wp_env> <wp_site_id> <wp_url> [--debug | --quiet] [DEPRECATED] | ||
jahia2wp.py generate-one <wp_env> <wp_site_id> <wp_url> [--debug | --quiet] [DEPRECATED] | ||
[--wp-title=<WP_TITLE> --admin-password=<ADMIN_PASSWORD>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A priori pas nécessaire de passer le wp_site_id de la sorte.
Complique l'utilisation de la CLI.
On devrait viser la simplification (par ex enlever wp_env 😏 )
src/tests/test_jahia2wp.py
Outdated
# /srv/test/localhost/htdocs/;KO;;;;; | ||
# /srv/test/localhost/htdocs/unittest;ok;http://localhost/unittest;4.8;wp_""" | ||
# assert Utils.run_command('python %s inventory %s /srv/test/localhost' | ||
# % (SCRIPT_FILE, TEST_ENV)).startswith(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pourquoi commenter ?
src/utils.py
Outdated
backup_listed_incremental_file, | ||
source_path | ||
) | ||
logging.debug("Command to generate tar file: {}".format(command)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
à priori déjà loggué dans run_command (ligne suivante)
src/utils.py
Outdated
backup_listed_incremental_file, | ||
source_path | ||
) | ||
logging.debug("Command to generate tar file: {}".format(command)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
si jamais, les fonctions de log ne doivent pas utilser format, mais passer les arguments de formatage en argument de fonction:
logging.debug("Command to generate tar file: %s", command)
src/wordpress/config.py
Outdated
# ",".join([wp_user.username for wp_user in wp_config.admins]), | ||
# ) | ||
# else: | ||
# yield WPResult(wp_config.wp_site.path, "KO", "", "", "", "", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pourquoi commenter ?
src/wordpress/backup.py
Outdated
Backup types: | ||
There are 2 types of backup : | ||
- full : Full backup. | ||
- inc : Incremental backup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
préciser qu'il s'agit juste des fichiers
src/wordpress/backup.py
Outdated
A backup of a WordPress site contains : | ||
- copy of all .php file (tar files) | ||
- a dump of the database (.sql file) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
préciser qu'on a les médias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
et les assets :)
src/wordpress/backup.py
Outdated
The content difference between incremental tar files are saved in the list file. | ||
""" | ||
|
||
BACKUP_ROOT_DIR = "../data/backups/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pas une bonne idée les chemins relatifs dans le code
src/wordpress/backup.py
Outdated
|
||
|
||
class WPBackup: | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On propose une autre façon de structurer les fichiers:
backups
├── site_id_1
│ ├── 2017-10-31
│ │ ├── full-2017-10-31-09-45.tar
│ │ ├── inc-2017-11-01-23-00.tar
│ │ ├── inc-2017-11-02-23-01.tar
│ │ └── inc-2017-11-03-23-10.tar
│ └── 2017-11-06
│ └── full-2017-11-06-09-46.tar
├── site_id_2
│ └── 2017-11-06
│ ├── full-2017-11-06-09-47.tar
│ └── inc-2017-11-06-09-46.tar
└── site_id_3
Ca évite d'utiliser des numéros (et de les maintenir/générer) et ca simplifie l'exploitation/maintenance
src/wordpress/backup.py
Outdated
from utils import Utils | ||
|
||
|
||
class WPBackup: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs tests
* origin: (33 commits) added doc moved WPTheme/PluginConfig to dedicated files themes/plugin.py Use var defined in 'settings.py' instead of hard-coded string Use site folder as 'wp_site_id' Small bug fix Change way to generate path, add var for plugin source Change function/option name Use wp_site_id instead of site_name (which is not unique) Use WPSite to create instance instead of openshift_env and wp_site_url Small bug fix Workaround for relative path to fix Travis checks Change how class is displayed Change display way PEP8 compliant Add short doc (very short) Add feature to dump plugin configuration Updated configuration for Add-To-Any, fits to new way to do things Change WP tables infos location (now outside class), prepare to use 'wp site id' instead of 'wp site name', PEP8 Use values defined in 'settings.py' and some cosmetic changes Replace way to configure plugin options. No more WPCLI... ...
From issue: #53
high level:
new commands
backup
andbackup-many
to backup one single site or all sites in source of trust.Backups are
full
by default, but can beinc
remental by using option--backup-type
new environment variable
BACKUP_PATH
to define where to store backups (by default:jahia2wp/data/backups
)low level:
A backup of a WordPress site relies on a
WPConfig
, and is called/used in a similar way asWPGenerator
. It creates three files:.tar
of all WP files (php, assets, media).list
reference file for incremental backups.sql
dump of the databaseBackups are stored in
BACKUP_PATH
(by default:jahia2wp/data/backups
), with the following name convention:<wp_site_name>[_<timestamp>]_fullN[_incM].<tar|list|sql>
DISCLAIMER: next iteration might revise this structure for something more easily exploitable, such as: