diff --git a/auto_backup/README.rst b/auto_backup/README.rst index 42e5abc6292..b9dcee52ae1 100644 --- a/auto_backup/README.rst +++ b/auto_backup/README.rst @@ -17,13 +17,13 @@ Database Auto-Backup :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/16.0/auto_backup + :target: https://github.com/OCA/server-tools/tree/18.0/auto_backup :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-auto_backup + :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-auto_backup :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,16 +38,17 @@ A tool for all your back-ups, internal and external! Installation ============ -Before installing this module, you need to execute:: +Before installing this module, you need to execute: - pip3 install pysftp==0.2.9 +:: + + pip3 install pysftp==0.2.9 Configuration ============= -Go to *Settings -> Database Structure -> Automated Backup* to -create your configurations for each database that you needed -to backups. +Go to *Settings -> Database Structure -> Automated Backup* to create +your configurations for each database that you needed to backups. Usage ===== @@ -58,10 +59,10 @@ through an encrypted tunnel. You can even specify how long local backups and external backups should be kept, automatically! Connect with an FTP Server -~~~~~~~~~~~~~~~~~~~~~~~~~~ +-------------------------- Keep your data safe, through an SSH tunnel! -------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Want to go even further and write your backups to an external server? You can with this module! Specify the credentials to the server, specify @@ -70,10 +71,10 @@ through an SSH (encrypted) tunnel, thanks to pysftp, so your data is safe! Test connection -~~~~~~~~~~~~~~~ +--------------- Checks your credentials in one click ------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Want to make sure if the connection details are correct and if Odoo can automatically write them to the remote server? Simply click on the ‘Test @@ -81,33 +82,34 @@ SFTP Connection’ button and you will get message telling you if everything is OK, or what is wrong! E-mail on backup failure -~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------ Stay informed of problems, automatically! ------------------------------------------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Do you want to know if the database backup succeeded or failed? Subscribe to -the corresponding backup setting notification type. +Do you want to know if the database backup succeeded or failed? +Subscribe to the corresponding backup setting notification type. Run backups when you want -~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------- From the backups configuration list, press *More > Execute backup(s)* to manually execute the selected processes. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot +|Try me on Runbot| + +.. |Try me on Runbot| image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :target: https://runbot.odoo-community.org/runbot/149/11.0 Known issues / Roadmap ====================== -* On larger databases, it is possible that backups will die due to Odoo server - settings. In order to circumvent this without frivolously changing settings, - you need to run the backup from outside of the main Odoo instance. How to do - this is outlined in `this blog post - `_. -* Backups won't work if list_db=False is configured in the instance. +- On larger databases, it is possible that backups will die due to Odoo + server settings. In order to circumvent this without frivolously + changing settings, you need to run the backup from outside of the + main Odoo instance. How to do this is outlined in `this blog + post `__. +- Backups won't work if list_db=False is configured in the instance. Bug Tracker =========== @@ -115,7 +117,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -123,7 +125,7 @@ Credits ======= Authors -~~~~~~~ +------- * Yenthe Van Ginneken * Agile Business Group @@ -132,20 +134,20 @@ Authors * AdaptiveCity Contributors -~~~~~~~~~~~~ - -* Yenthe Van Ginneken -* Alessio Gerace -* Jairo Llopis -* Dave Lasley -* Andrea Stirpe -* Aitor Bouzas -* Simone Vanin -* Vu Nguyen Anh -* Alex Comba +------------ + +- Yenthe Van Ginneken +- Alessio Gerace +- Jairo Llopis +- Dave Lasley +- Andrea Stirpe +- Aitor Bouzas +- Simone Vanin +- Vu Nguyen Anh +- Alex Comba Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -157,6 +159,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/server-tools `_ project on GitHub. +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auto_backup/models/db_backup.py b/auto_backup/models/db_backup.py index b773484cbc7..1a7f33dbdb6 100644 --- a/auto_backup/models/db_backup.py +++ b/auto_backup/models/db_backup.py @@ -106,14 +106,9 @@ def _compute_name(self): """Get the right summary for this job.""" for rec in self: if rec.method == "local": - rec.name = "%s @ localhost" % rec.folder + rec.name = f"{rec.folder} @ localhost" elif rec.method == "sftp": - rec.name = "sftp://%s@%s:%d%s" % ( - rec.sftp_user, - rec.sftp_host, - rec.sftp_port, - rec.folder, - ) + rec.name = f"sftp://{rec.sftp_user}@{rec.sftp_host}:{rec.sftp_port}{rec.folder}" @api.constrains("folder", "method") def _check_folder(self): @@ -156,7 +151,7 @@ def action_backup(self): try: os.makedirs(rec.folder, exist_ok=True) except OSError as exc: - _logger.exception("Action backup - OSError: %s" % exc) + _logger.exception(f"Action backup - OSError: {exc}") with open(os.path.join(rec.folder, filename), "wb") as destiny: # Copy the cached backup @@ -177,7 +172,6 @@ def action_backup(self): for rec in sftp: filename = self.filename(datetime.now(), ext=rec.backup_format) with rec.backup_log(): - cached = db.dump_db( self.env.cr.dbname, None, backup_format=rec.backup_format ) @@ -188,9 +182,7 @@ def action_backup(self): try: remote.makedirs(rec.folder, exist_ok=True) except pysftp.ConnectionException as exc: - _logger.exception( - "pysftp ConnectionException: %s" % exc - ) + _logger.exception(f"pysftp ConnectionException: {exc}") # Copy cached backup to remote server with remote.open( @@ -211,18 +203,17 @@ def action_backup_all(self): def backup_log(self): """Log a backup result.""" try: - _logger.info("Starting database backup: %s", self.name) + _logger.info(f"Starting database backup: {self.name}") yield except Exception: - _logger.exception("Database backup failed: %s", self.name) + _logger.exception(f"Database backup failed: {self.name}") escaped_tb = tools.html_escape(traceback.format_exc()) self.message_post( # pylint: disable=translation-required - body="

%s

%s
" - % (_("Database backup failed."), escaped_tb), + body=f"

{_('Database backup failed.')}

{escaped_tb}
", subtype_id=self.env.ref("auto_backup.mail_message_subtype_failure").id, ) else: - _logger.info("Database backup succeeded: %s", self.name) + _logger.info(f"Database backup succeeded: {self.name}") self.message_post(body=_("Database backup succeeded.")) def cleanup(self): @@ -231,15 +222,13 @@ def cleanup(self): for rec in self.filtered("days_to_keep"): with rec.cleanup_log(): bu_format = rec.backup_format - file_extension = bu_format == "zip" and "dump.zip" or bu_format + file_extension = "dump.zip" if bu_format == "zip" else bu_format oldest = self.filename( now - timedelta(days=rec.days_to_keep), bu_format ) if rec.method == "local": - for name in iglob( - os.path.join(rec.folder, "*.%s" % file_extension) - ): + for name in iglob(os.path.join(rec.folder, f"*.{file_extension}")): if os.path.basename(name) < oldest: os.unlink(name) @@ -247,30 +236,30 @@ def cleanup(self): with rec.sftp_connection() as remote: for name in remote.listdir(rec.folder): if ( - name.endswith(".%s" % file_extension) + name.endswith(f".{file_extension}") and os.path.basename(name) < oldest ): - remote.unlink("{}/{}".format(rec.folder, name)) + remote.unlink(f"{rec.folder}/{name}") @contextmanager def cleanup_log(self): """Log a possible cleanup failure.""" self.ensure_one() try: - _logger.info( - "Starting cleanup process after database backup: %s", self.name - ) + _logger.info(f"Starting cleanup process after database backup: {self.name}") yield except Exception: - _logger.exception("Cleanup of old database backups failed: %s") + _logger.exception(f"Cleanup of old database backups failed: {self.name}") escaped_tb = tools.html_escape(traceback.format_exc()) self.message_post( # pylint: disable=translation-required - body="

%s

%s
" - % (_("Cleanup of old database backups failed."), escaped_tb), + body=( + f"

{_('Cleanup of old database backups failed.')}

" + f"
{escaped_tb}
" + ), subtype_id=self.env.ref("auto_backup.failure").id, ) else: - _logger.info("Cleanup of old database backups succeeded: %s", self.name) + _logger.info(f"Cleanup of old database backups succeeded: {self.name}") @staticmethod def filename(when, ext="zip"): diff --git a/auto_backup/pyproject.toml b/auto_backup/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/auto_backup/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/auto_backup/readme/CONFIGURE.md b/auto_backup/readme/CONFIGURE.md new file mode 100644 index 00000000000..d8d33311203 --- /dev/null +++ b/auto_backup/readme/CONFIGURE.md @@ -0,0 +1,2 @@ +Go to *Settings -\> Database Structure -\> Automated Backup* to create +your configurations for each database that you needed to backups. diff --git a/auto_backup/readme/CONFIGURE.rst b/auto_backup/readme/CONFIGURE.rst deleted file mode 100644 index 406e814877b..00000000000 --- a/auto_backup/readme/CONFIGURE.rst +++ /dev/null @@ -1,3 +0,0 @@ -Go to *Settings -> Database Structure -> Automated Backup* to -create your configurations for each database that you needed -to backups. diff --git a/auto_backup/readme/CONTRIBUTORS.md b/auto_backup/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..09b20557dd3 --- /dev/null +++ b/auto_backup/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- Yenthe Van Ginneken \<\> +- Alessio Gerace \<\> +- Jairo Llopis \<\> +- Dave Lasley \<\> +- Andrea Stirpe \<\> +- Aitor Bouzas \<\> +- Simone Vanin \<\> +- Vu Nguyen Anh \<\> +- Alex Comba \<\> diff --git a/auto_backup/readme/CONTRIBUTORS.rst b/auto_backup/readme/CONTRIBUTORS.rst deleted file mode 100644 index bac3ca7b129..00000000000 --- a/auto_backup/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,9 +0,0 @@ -* Yenthe Van Ginneken -* Alessio Gerace -* Jairo Llopis -* Dave Lasley -* Andrea Stirpe -* Aitor Bouzas -* Simone Vanin -* Vu Nguyen Anh -* Alex Comba diff --git a/auto_backup/readme/DESCRIPTION.rst b/auto_backup/readme/DESCRIPTION.md similarity index 100% rename from auto_backup/readme/DESCRIPTION.rst rename to auto_backup/readme/DESCRIPTION.md diff --git a/auto_backup/readme/INSTALL.md b/auto_backup/readme/INSTALL.md new file mode 100644 index 00000000000..39c51f6db89 --- /dev/null +++ b/auto_backup/readme/INSTALL.md @@ -0,0 +1,3 @@ +Before installing this module, you need to execute: + + pip3 install pysftp==0.2.9 diff --git a/auto_backup/readme/INSTALL.rst b/auto_backup/readme/INSTALL.rst deleted file mode 100644 index 3093fb989f2..00000000000 --- a/auto_backup/readme/INSTALL.rst +++ /dev/null @@ -1,3 +0,0 @@ -Before installing this module, you need to execute:: - - pip3 install pysftp==0.2.9 diff --git a/auto_backup/readme/ROADMAP.md b/auto_backup/readme/ROADMAP.md new file mode 100644 index 00000000000..93e7ad75415 --- /dev/null +++ b/auto_backup/readme/ROADMAP.md @@ -0,0 +1,6 @@ +- On larger databases, it is possible that backups will die due to Odoo + server settings. In order to circumvent this without frivolously + changing settings, you need to run the backup from outside of the main + Odoo instance. How to do this is outlined in [this blog + post](https://blog.laslabs.com/2016/10/running-python-scripts-within-odoos-environment/). +- Backups won't work if list_db=False is configured in the instance. diff --git a/auto_backup/readme/ROADMAP.rst b/auto_backup/readme/ROADMAP.rst deleted file mode 100644 index e96ef407e25..00000000000 --- a/auto_backup/readme/ROADMAP.rst +++ /dev/null @@ -1,6 +0,0 @@ -* On larger databases, it is possible that backups will die due to Odoo server - settings. In order to circumvent this without frivolously changing settings, - you need to run the backup from outside of the main Odoo instance. How to do - this is outlined in `this blog post - `_. -* Backups won't work if list_db=False is configured in the instance. diff --git a/auto_backup/readme/USAGE.md b/auto_backup/readme/USAGE.md new file mode 100644 index 00000000000..c314fad9b85 --- /dev/null +++ b/auto_backup/readme/USAGE.md @@ -0,0 +1,37 @@ +Keep your Odoo data safe with this module. Take automated back-ups, +remove them automatically and even write them to an external server +through an encrypted tunnel. You can even specify how long local backups +and external backups should be kept, automatically! + +## Connect with an FTP Server + +### Keep your data safe, through an SSH tunnel! + +Want to go even further and write your backups to an external server? +You can with this module! Specify the credentials to the server, specify +a path and everything will be backed up automatically. This is done +through an SSH (encrypted) tunnel, thanks to pysftp, so your data is +safe! + +## Test connection + +### Checks your credentials in one click + +Want to make sure if the connection details are correct and if Odoo can +automatically write them to the remote server? Simply click on the ‘Test +SFTP Connection’ button and you will get message telling you if +everything is OK, or what is wrong! + +## E-mail on backup failure + +### Stay informed of problems, automatically! + +Do you want to know if the database backup succeeded or failed? +Subscribe to the corresponding backup setting notification type. + +## Run backups when you want + +From the backups configuration list, press *More \> Execute backup(s)* +to manually execute the selected processes. + +[![Try me on Runbot](https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas)](https://runbot.odoo-community.org/runbot/149/11.0) diff --git a/auto_backup/readme/USAGE.rst b/auto_backup/readme/USAGE.rst deleted file mode 100644 index bc3607e22a4..00000000000 --- a/auto_backup/readme/USAGE.rst +++ /dev/null @@ -1,46 +0,0 @@ -Keep your Odoo data safe with this module. Take automated back-ups, -remove them automatically and even write them to an external server -through an encrypted tunnel. You can even specify how long local backups -and external backups should be kept, automatically! - -Connect with an FTP Server -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Keep your data safe, through an SSH tunnel! -------------------------------------------- - -Want to go even further and write your backups to an external server? -You can with this module! Specify the credentials to the server, specify -a path and everything will be backed up automatically. This is done -through an SSH (encrypted) tunnel, thanks to pysftp, so your data is -safe! - -Test connection -~~~~~~~~~~~~~~~ - -Checks your credentials in one click ------------------------------------- - -Want to make sure if the connection details are correct and if Odoo can -automatically write them to the remote server? Simply click on the ‘Test -SFTP Connection’ button and you will get message telling you if -everything is OK, or what is wrong! - -E-mail on backup failure -~~~~~~~~~~~~~~~~~~~~~~~~ - -Stay informed of problems, automatically! ------------------------------------------ - -Do you want to know if the database backup succeeded or failed? Subscribe to -the corresponding backup setting notification type. - -Run backups when you want -~~~~~~~~~~~~~~~~~~~~~~~~~ - -From the backups configuration list, press *More > Execute backup(s)* to -manually execute the selected processes. - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/11.0 diff --git a/auto_backup/static/description/index.html b/auto_backup/static/description/index.html index fc7f70ffb1b..98c458704a8 100644 --- a/auto_backup/static/description/index.html +++ b/auto_backup/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -369,7 +368,7 @@

Database Auto-Backup

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:253605cf2842f470efc655cf4624d82ff984c722aa0cb3c292c2ad1120b80358 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

A tool for all your back-ups, internal and external!

Table of contents

@@ -411,9 +410,8 @@

Installation

Configuration

-

Go to Settings -> Database Structure -> Automated Backup to -create your configurations for each database that you needed -to backups.

+

Go to Settings -> Database Structure -> Automated Backup to create +your configurations for each database that you needed to backups.

Usage

@@ -446,26 +444,25 @@

Checks your credentials in one cl

E-mail on backup failure

Stay informed of problems, automatically!

-

Do you want to know if the database backup succeeded or failed? Subscribe to -the corresponding backup setting notification type.

+

Do you want to know if the database backup succeeded or failed? +Subscribe to the corresponding backup setting notification type.

Run backups when you want

From the backups configuration list, press More > Execute backup(s) to manually execute the selected processes.

- -Try me on Runbot - +

Try me on Runbot

Known issues / Roadmap

    -
  • On larger databases, it is possible that backups will die due to Odoo server -settings. In order to circumvent this without frivolously changing settings, -you need to run the backup from outside of the main Odoo instance. How to do -this is outlined in this blog post.
  • +
  • On larger databases, it is possible that backups will die due to Odoo +server settings. In order to circumvent this without frivolously +changing settings, you need to run the backup from outside of the +main Odoo instance. How to do this is outlined in this blog +post.
  • Backups won’t work if list_db=False is configured in the instance.
@@ -474,7 +471,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -506,13 +503,11 @@

Contributors

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/server-tools project on GitHub.

+

This module is part of the OCA/server-tools project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/auto_backup/tests/test_db_backup.py b/auto_backup/tests/test_db_backup.py index 70588e0d95a..50ee1d194c9 100644 --- a/auto_backup/tests/test_db_backup.py +++ b/auto_backup/tests/test_db_backup.py @@ -22,26 +22,26 @@ model = "odoo.addons.auto_backup.models.db_backup" -class_name = "%s.DbBackup" % model +class_name = f"{model}.DbBackup" class TestConnectionException(pysftp.ConnectionException): def __init__(self): - super(TestConnectionException, self).__init__("test", "test") + super().__init__("test", "test") class TestDbBackup(common.TransactionCase): def setUp(self): - super(TestDbBackup, self).setUp() + super().setUp() self.Model = self.env["db.backup"] @contextmanager def mock_assets(self): """It provides mocked core assets""" self.path_join_val = "/this/is/a/path" - with patch("%s.db" % model) as db: - with patch("%s.os" % model) as os: - with patch("%s.shutil" % model) as shutil: + with patch(f"{model}.db") as db: + with patch(f"{model}.os") as os: + with patch(f"{model}.shutil") as shutil: os.path.join.return_value = self.path_join_val yield { "db": db, @@ -52,10 +52,10 @@ def mock_assets(self): @contextmanager def patch_filtered_sftp(self, record): """It patches filtered record and provides a mock""" - with patch("%s.filtered" % class_name) as filtered: + with patch(f"{class_name}.filtered") as filtered: filtered.side_effect = [], [record] - with patch("%s.backup_log" % class_name): - with patch("%s.sftp_connection" % class_name): + with patch(f"{class_name}.backup_log"): + with patch(f"{class_name}.sftp_connection"): yield filtered def new_record(self, method="sftp"): @@ -76,16 +76,11 @@ def new_record(self, method="sftp"): def test_compute_name_sftp(self): """It should create proper SFTP URI""" rec_id = self.new_record() - self.assertEqual( - "sftp://%(user)s@%(host)s:%(port)s%(folder)s" - % { - "user": self.vals["sftp_user"], - "host": self.vals["sftp_host"], - "port": self.vals["sftp_port"], - "folder": self.vals["folder"], - }, - rec_id.name, + expected_uri = ( + f"sftp://{self.vals['sftp_user']}@{self.vals['sftp_host']}:" + f"{self.vals['sftp_port']}{self.vals['folder']}" ) + self.assertEqual(expected_uri, rec_id.name) def test_check_folder(self): """It should not allow recursive backups""" @@ -93,26 +88,25 @@ def test_check_folder(self): with self.assertRaises(UserError): rec_id.write( { - "folder": "%s/another/path" - % tools.config.filestore(self.env.cr.dbname), + "folder": ( + f"{tools.config.filestore(self.env.cr.dbname)}" "/another/path" + ), } ) - @patch("%s._" % model) + @patch(f"{model}._") def test_action_sftp_test_connection_success(self, _): """It should raise connection succeeded warning""" - with patch("%s.sftp_connection" % class_name, new_callable=PropertyMock): + with patch(f"{class_name}.sftp_connection", new_callable=PropertyMock): rec_id = self.new_record() with self.assertRaises(UserError): rec_id.action_sftp_test_connection() _.assert_called_once_with("Connection Test Succeeded!") - @patch("%s._" % model) + @patch(f"{model}._") def _test_action_sftp_test_connection_fail(self, _): """It should raise connection fail warning""" - with patch( - "%s.sftp_connection" % class_name, new_callable=PropertyMock - ) as conn: + with patch(f"{class_name}.sftp_connection", new_callable=PropertyMock) as conn: rec_id = self.new_record() conn().side_effect = TestConnectionException with self.assertRaises(UserError): @@ -132,7 +126,7 @@ def test_action_backup_local_cleanup(self): rec_id = self.new_record("local") old_date = datetime.now() - timedelta(days=3) filename = rec_id.filename(old_date) - with patch("%s.datetime" % model) as mock_date: + with patch(f"{model}.datetime") as mock_date: mock_date.now.return_value = old_date rec_id.action_backup() generated_backup = [f for f in os.listdir(rec_id.folder) if f >= filename] @@ -148,7 +142,7 @@ def _test_action_backup_sftp_mkdirs(self): rec_id = self.new_record() with self.mock_assets(): with self.patch_filtered_sftp(rec_id): - with patch("%s.cleanup" % class_name, new_callable=PropertyMock): + with patch(f"{class_name}.cleanup", new_callable=PropertyMock): conn = rec_id.sftp_connection().__enter__() rec_id.action_backup() conn.makedirs.assert_called_once_with(rec_id.folder) @@ -158,7 +152,7 @@ def _test_action_backup_sftp_mkdirs_conn_exception(self): rec_id = self.new_record() with self.mock_assets(): with self.patch_filtered_sftp(rec_id): - with patch("%s.cleanup" % class_name, new_callable=PropertyMock): + with patch(f"{class_name}.cleanup", new_callable=PropertyMock): conn = rec_id.sftp_connection().__enter__() conn.makedirs.side_effect = TestConnectionException rec_id.action_backup() @@ -170,7 +164,7 @@ def test_action_backup_sftp_remote_open(self): rec_id = self.new_record() with self.mock_assets() as assets: with self.patch_filtered_sftp(rec_id): - with patch("%s.cleanup" % class_name, new_callable=PropertyMock): + with patch(f"{class_name}.cleanup", new_callable=PropertyMock): conn = rec_id.sftp_connection().__enter__() rec_id.action_backup() conn.open.assert_called_once_with(assets["os"].path.join(), "wb") @@ -178,18 +172,18 @@ def test_action_backup_sftp_remote_open(self): def test_action_backup_all_search(self): """It should search all records""" rec_id = self.new_record() - with patch("%s.search" % class_name, new_callable=PropertyMock): + with patch(f"{class_name}.search", new_callable=PropertyMock): rec_id.action_backup_all() rec_id.search.assert_called_once_with([]) def test_action_backup_all_return(self): """It should return result of backup operation""" rec_id = self.new_record() - with patch("%s.search" % class_name, new_callable=PropertyMock): + with patch(f"{class_name}.search", new_callable=PropertyMock): res = rec_id.action_backup_all() self.assertEqual(rec_id.search().action_backup(), res) - @patch("%s.pysftp" % model) + @patch(f"{model}.pysftp") def test_sftp_connection_init_passwd(self, pysftp): """It should initiate SFTP connection w/ proper args and pass""" rec_id = self.new_record() @@ -201,7 +195,7 @@ def test_sftp_connection_init_passwd(self, pysftp): password=rec_id.sftp_password, ) - @patch("%s.pysftp" % model) + @patch(f"{model}.pysftp") def test_sftp_connection_init_key(self, pysftp): """It should initiate SFTP connection w/ proper args and key""" rec_id = self.new_record() @@ -215,7 +209,7 @@ def test_sftp_connection_init_key(self, pysftp): private_key_pass=rec_id.sftp_password, ) - @patch("%s.pysftp" % model) + @patch(f"{model}.pysftp") def test_sftp_connection_return(self, pysftp): """It should return new sftp connection""" rec_id = self.new_record() diff --git a/auto_backup/view/db_backup_view.xml b/auto_backup/view/db_backup_view.xml index d4dc9a95168..c21ef4fc940 100644 --- a/auto_backup/view/db_backup_view.xml +++ b/auto_backup/view/db_backup_view.xml @@ -49,12 +49,12 @@
Automatic backups of the database can be scheduled as follows:
    -
  1. Go to Settings / Technical / Automation / Scheduled Actions.
  2. -
  3. Search the action named 'Backup scheduler'.
  4. -
  5. Set the scheduler to active and fill in how often you want backups generated.
  6. -
+
  • Go to Settings / Technical / Automation / Scheduled Actions.
  • +
  • Search the action named 'Backup scheduler'.
  • +
  • Set the scheduler to active and fill in how often you want backups generated.
  • +
    diff --git a/requirements.txt b/requirements.txt index 181d5381d9f..3ed615de305 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ # generated from manifests external_dependencies astor +cryptography dataclasses odoorpc openupgradelib sentry_sdk>=2.0.0 +pysftp