Skip to content

Commit 76163e3

Browse files
committed
move CLI stuff from pickle_schema into schema-tool
1 parent 2dbe9f4 commit 76163e3

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

pickle_schema.py

100755100644
+1-10
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
#
1717
# This document is not confidential.
1818

19-
import MySQLdb
2019
import pickle
21-
import sys
2220
import os
2321

22+
import MySQLdb
2423

2524
class BzSchemaPickleException(Exception):
2625
def __init__(self, message):
@@ -97,14 +96,6 @@ def pickle_schema(schema_version, db_name):
9796
f.close()
9897

9998

100-
if __name__ == "__main__":
101-
try:
102-
(schema_version, db_name) = sys.argv[1:]
103-
except ValueError:
104-
print("Please pass the schema version and the database name.")
105-
sys.exit()
106-
pickle_schema(schema_version, db_name)
107-
10899
# A. REFERENCES
109100
#
110101
#

schema-tool

+27-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Perforce Defect Tracking Integration Project
55
# <http://www.ravenbrook.com/project/p4dti/>
66
#
7-
# MAKE_SCHEMA_DOC.PY -- GENERATE BUGZILLA SCHEMA DOCUMENTATION
7+
# SCHEMA-TOOL -- COMMAND LINE INTERFACE TO SCHEMA MODULES
88
#
9-
# Nick Barnes, Ravenbrook Limited, 2003-07-07
9+
# David Miller, Zarro Boogs Corporation, 2024-05-04
1010
#
1111
#
1212
# 1. INTRODUCTION
@@ -28,10 +28,10 @@ import argparse
2828
import subprocess
2929
from pprint import pformat
3030
from black import Mode, format_str
31-
from collections import OrderedDict
3231

3332
import schema_remarks
34-
from make_schema_doc import BzSchemaProcessingException, make_tables, version_compare
33+
from make_schema_doc import BzSchemaProcessingException, make_tables
34+
from pickle_schema import pickle_schema
3535

3636

3737
def write_file(first, last, file):
@@ -259,7 +259,8 @@ def generate_schema_remarks(args):
259259
output = template.format(**var_dict)
260260
outfile.write(output)
261261
subprocess.run(
262-
["diff", "-u", "--color", "schema_remarks.py", "schema_remarks_new.py"]
262+
["diff", "-u", "--color", "schema_remarks.py", "schema_remarks_new.py"],
263+
check=True,
263264
)
264265
print("Wrote changes to schema_remarks_new.py.")
265266
print("If these changes are okay, move it overtop of schema_remarks.py")
@@ -306,6 +307,9 @@ def validate_schema_remarks(_args):
306307
sys.exit()
307308
print("Versions validated.")
308309

310+
def pickle_parser(args):
311+
pickle_schema(args.version, args.db_name)
312+
print("Success!")
309313

310314
if __name__ == "__main__":
311315
parser = argparse.ArgumentParser(
@@ -400,6 +404,22 @@ if __name__ == "__main__":
400404
help="The destination version of the schema to compare",
401405
)
402406
parser_generate.set_defaults(func=generate_schema_remarks)
407+
parser_pickle = subparsers.add_parser(
408+
"pickle",
409+
help="Generate a pickle file for a specific version",
410+
description="Generate a pickle file for a specific version",
411+
)
412+
parser_pickle.add_argument(
413+
'version',
414+
metavar = 'version',
415+
help="The Bugzilla version number associated with the schema",
416+
)
417+
parser_pickle.add_argument(
418+
'db_name',
419+
metavar='db_name',
420+
help="The name of the database to analyze"
421+
)
422+
parser_pickle.set_defaults(func=pickle_parser)
403423
main_args = parser.parse_args()
404424
main_args.func(main_args)
405425

@@ -408,12 +428,12 @@ if __name__ == "__main__":
408428
#
409429
# B. DOCUMENT HISTORY
410430
#
411-
# 2001-03-08 NB Created.
431+
# 2024-05-04 Created.
412432
#
413433
#
414434
# C. COPYRIGHT AND LICENSE
415435
#
416-
# This file is copyright (c) 2001 Perforce Software, Inc. All rights
436+
# This file is copyright (c) 2024 Bugzilla Project Contributors. All rights
417437
# reserved.
418438
#
419439
# Redistribution and use in source and binary forms, with or without

updating.rst

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ For any given release of Bugzilla, the process goes something like this:
2020

2121
- If there are schema changes, or if you aren't sure, download the
2222
full Bugzilla release, do a vanilla install on your MySQL, then run
23-
``./pickle_schema.py version db_name``. For
23+
``./schema-tool pickle version db_name``. For
2424
instance::
2525

26-
> ./pickle_schema.py 3.8.12 bugs
26+
> ./schema-tool pickle 3.8.12 bugs
2727

28-
For this to work you will have to have MySQLdb (the Python MySQL interface
29-
library). You can install it with ``pip install mysqlclient``. It will use
30-
your database host and credentials from the ``[pickle_schema]`` section of
31-
``.my.cnf`` in your home directory. For example
28+
This uses your database host and credentials from the ``[pickle_schema]``
29+
section of ``.my.cnf`` in your home directory. For example
3230

3331
.. code-block:: ini
3432

0 commit comments

Comments
 (0)