Skip to content

Commit 0f31746

Browse files
committed
Review of the --clean-all argument.
Indeed, before this patch, if `--clean-all` was use along with `--database-type mysql` for example, the whois database table was cleaned which is not a good idea as it force the system to retest everything. Causing the tests to run for much more time that "expected". Contributors: * @mitchellkrogza
1 parent 5d174ee commit 0f31746

File tree

6 files changed

+56
-26
lines changed

6 files changed

+56
-26
lines changed

PyFunceble/__init__.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
# We set our project name.
9595
NAME = "PyFunceble"
9696
# We set out project version.
97-
VERSION = "2.1.0.dev (Green Galago: Skitterbug)"
97+
VERSION = "2.2.0.dev (Green Galago: Skitterbug)"
9898

9999
# We set the list of windows "platforms"
100100
WINDOWS_PLATFORMS = ["windows", "cygwin", "cygwin_nt-10.0"]
@@ -1283,12 +1283,6 @@ def _command_line(): # pragma: no cover pylint: disable=too-many-branches,too-m
12831283
{"travis_autosave_minutes": ARGS.autosave_minutes}
12841284
)
12851285

1286-
if ARGS.clean:
1287-
Clean(None)
1288-
1289-
if ARGS.clean_all:
1290-
Clean(None, ARGS.clean_all)
1291-
12921286
if ARGS.cmd:
12931287
CONFIGURATION.update({"command": ARGS.cmd})
12941288

@@ -1345,9 +1339,6 @@ def _command_line(): # pragma: no cover pylint: disable=too-many-branches,too-m
13451339
if ARGS.debug:
13461340
CONFIGURATION.update({"debug": Preset().switch("debug")})
13471341

1348-
if ARGS.directory_structure:
1349-
DirectoryStructure()
1350-
13511342
if ARGS.dns:
13521343
CONFIGURATION.update({"dns_server": ARGS.dns})
13531344

@@ -1378,9 +1369,6 @@ def _command_line(): # pragma: no cover pylint: disable=too-many-branches,too-m
13781369
{"active": Preset().switch(HTTP_CODE["active"], True)}
13791370
)
13801371

1381-
if ARGS.iana:
1382-
IANA().update()
1383-
13841372
if ARGS.idna:
13851373
CONFIGURATION.update(
13861374
{"idna_conversion": Preset().switch("idna_conversion")}
@@ -1433,12 +1421,6 @@ def _command_line(): # pragma: no cover pylint: disable=too-many-branches,too-m
14331421
if ARGS.processes and ARGS.processes >= 2:
14341422
CONFIGURATION.update({"maximal_processes": ARGS.processes})
14351423

1436-
if ARGS.production:
1437-
Production()
1438-
1439-
if ARGS.public_suffix:
1440-
PublicSuffix().update()
1441-
14421424
if ARGS.quiet:
14431425
CONFIGURATION.update({"quiet": Preset().switch("quiet")})
14441426

@@ -1481,6 +1463,24 @@ def _command_line(): # pragma: no cover pylint: disable=too-many-branches,too-m
14811463
if not CONFIGURATION["quiet"]:
14821464
CLICore.colorify_logo(home=True)
14831465

1466+
if ARGS.clean:
1467+
Clean(None)
1468+
1469+
if ARGS.clean_all:
1470+
Clean(None, ARGS.clean_all)
1471+
1472+
if ARGS.directory_structure:
1473+
DirectoryStructure()
1474+
1475+
if ARGS.iana:
1476+
IANA().update()
1477+
1478+
if ARGS.production:
1479+
Production()
1480+
1481+
if ARGS.public_suffix:
1482+
PublicSuffix().update()
1483+
14841484
# We compare the versions (upstream and local) and in between.
14851485
Version().compare()
14861486

PyFunceble/clean.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ def almost_everything(self, clean_all=False):
256256

257257
sqlite_db = SQLite()
258258

259-
for database_name in sqlite_db.tables.values():
259+
for database_name in [
260+
y for x, y in sqlite_db.tables.items() if x != "whois"
261+
]:
260262
query = "DELETE FROM {0}".format(database_name)
261263

262264
sqlite_db.cursor.execute(query)
@@ -266,7 +268,9 @@ def almost_everything(self, clean_all=False):
266268

267269
mysql_db = MySQL()
268270

269-
for database_name in mysql_db.tables.values():
271+
for database_name in [
272+
y for x, y in mysql_db.tables.items() if x != "whois"
273+
]:
270274
query = "DELETE FROM {0}".format(database_name)
271275

272276
with mysql_db.get_connection() as cursor:

PyFunceble/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ def __init__(self, used=False):
563563
# We initiate the link to the upstream version file.
564564
# It is hard coded because we may not have the chance to have the
565565
# configuration file everytime we need it.
566-
upstream_link = "https://raw.githubusercontent.com/funilrys/PyFunceble/dev/version.yaml" # pylint: disable=line-too-long
566+
upstream_link = (
567+
"https://raw.githubusercontent.com/funilrys/PyFunceble/dev/version.yaml"
568+
) # pylint: disable=line-too-long
567569

568570
# We update the link according to our current version.
569571
upstream_link = self.right_url_from_version(upstream_link)

docs/components/databases.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ How do we manage them?
1919

2020
They consist of simple JSON files which are read and updated on the fly.
2121

22+
Warnings around Database (self) management
23+
------------------------------------------
24+
25+
.. warning::
26+
If you plan to delete everything and still manage to use PyFunceble in the future, please use the :code:`--clean-all` argument.
27+
28+
Indeed, it will delete everything which is related to what we generated except things like the whois database file/table
29+
which saves (almost) static data which can be reused in the future.
30+
31+
Actually, deleting for example the whois database file/table will just make your test run for a much longer time if you
32+
retest subject that used to be indexed into the whois database file/table.
33+
2234
Databases types
2335
===============
2436

@@ -28,7 +40,7 @@ we offer multiple database types which are (as per configuration) :code:`json` (
2840
Why different database types?
2941
-----------------------------
3042

31-
With the introduction of the multiprocessing logic, it became natural to introduce other database format as it's a nightmare to update a JSON formatted.
43+
With the introduction of the multiprocessing logic, it became natural to introduce other database format as it's a nightmare to update a JSON formatted file.
3244

3345
Indeed in order to write or use a JSON formatted database, we have to load it and overwrite it completly.
3446
It's great while working with a single CPU/process but as soon as we get out of that scope it become unmanagable.

docs/usage/from-a-terminal.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,19 @@ As it is sometimes needed to clean our :code:`output/` directory, this argument
6767
Clean all files under the output directory along with all file generated by PyFunceble.
6868

6969
.. warning::
70-
This really deletes everything we generated without any warning.
70+
This really deletes almost everything we generated without any warning.
71+
72+
.. note::
73+
We don't delete the whois database file/table because they are (almost) static data which
74+
are shared accross launches in your environment.
75+
76+
.. warning::
77+
If you plan to clean manually do not delete the whois database file or table as it will
78+
make your test finish under a much longer time as usual for you.
79+
80+
.. warning::
81+
If you don't combine this argument alongside with the :code:`--database-type` argument or its configurable equivalent,
82+
this argument will only clean the JSON formatted databases.
7183

7284
:code:`--cmd` "something"
7385
^^^^^^^^^^^^^^^^^^^^^^^^^

version.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
current_version: '2.1.0.dev (Green Galago: Skitterbug)'
1+
current_version: '2.2.0.dev (Green Galago: Skitterbug)'
22
deprecated: [0.0.0, 0.0.1, 0.65.0, 0.67.1, 0.68.0, 0.69.3, 0.69.5, 0.70.4, 0.71.2,
33
0.72.7, 0.73.1, 0.74.5, 0.75.1, 0.76.2, 0.77.0, 0.78.0, 0.79.1, 0.80.9, 0.81.8,
44
0.82.4, 0.83.2, 0.84.5, 0.85.0, 0.86.0, 0.87.1, 0.88.3, 0.89.3, 0.90.2, 0.91.1,
@@ -13,7 +13,7 @@ deprecated: [0.0.0, 0.0.1, 0.65.0, 0.67.1, 0.68.0, 0.69.3, 0.69.5, 0.70.4, 0.71.
1313
1.55.2, 1.56.0, 1.57.0, 1.58.0, 1.59.1, 1.60.0, 1.61.0, 1.62.0, 1.63.1, 1.64.1,
1414
1.65.0, 1.66.1, 1.67.2, 1.68.0, 1.69.0, 1.70.0, 1.71.0, 1.72.3, 1.73.3, 1.74.5,
1515
1.75.4, 1.77.0, 1.78.0, 1.79.1, 1.81.0, 1.82.5, 1.83.0, 1.84.0, 1.85.0, 1.86.0,
16-
1.87.0, 1.88.0, 1.89.0, 1.90.0, 1.91.0, 2.0.0]
16+
1.87.0, 1.88.0, 1.89.0, 1.90.0, 1.91.0, 2.0.0, 2.1.0]
1717
force_update:
1818
minimal_version: [0.0.0, 0.0.1, 0.82.5, 0.89.2, 0.94.3, 0.121.0, 0.140.0, 1.3.0]
1919
status: true

0 commit comments

Comments
 (0)