annotate make.py @ 2860:233d63abbdaf

reorder modernized blog.css rules to match basic blog.css sequence no code changes, rules remain unnecessarily inconsistent
author RogerHaase <haaserd@gmail.com>
date Tue, 02 Dec 2014 14:21:32 -0700
parents 9c036e6c2265
children 45d3cadb38c3
rev   line source
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
1 #!/usr/bin/python
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
2 # Copyright: 2013 MoinMoin:RogerHaase
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
3 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
4
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
5 """
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
6 make.py provides a menu of commands frequently used by moin2 developers and desktop wiki users.
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
7
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
8 - wraps a few commonly used moin commands, do "moin --help" for other alternatives
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
9 - adds default file names for selected moin commands (backup, restore, ...)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
10 - creates log files for functions with large output, extracts success/failure messages
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
11 - displays error messages if user tries to run commands out of sequence
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
12
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
13 usage (to display a menu of commands):
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
14
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
15 - unix: ./m
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
16 - windows: m
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
17
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
18 For make.py to work, it needs to know the name of a python executable and the location of a
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
19 virtual env. These needs are met by running "python quickinstall.py" after cloning the moin2
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
20 repository. quickinstall.py creates these files or symlink in the repo root:
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
21
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
22 - unix: m, activate
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
23 - windows: m.bat, activate.bat, deactivate.bat
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
24
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
25 Executing m.bat or ./m will run make.py. The name of the python executable is within the m.bat or ./m
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
26 script. The location of the virtual env is within the activate symlink or activate.bat.
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
27 Depending upon the command to be executed, some mix of the python executable
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
28 or activate will be used to construct a command string to pass to a subprocess call.
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
29 """
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
30
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
31 import os
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
32 import sys
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
33 import subprocess
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
34 import glob
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
35 import shutil
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
36 import fnmatch
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
37 from collections import Counter
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
38
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
39 import MoinMoin # validate python version
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
40
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
41
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
42 # text files created by commands with high volume output
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
43 QUICKINSTALL = 'm-quickinstall.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
44 PYTEST = 'm-pytest.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
45 CODING_STD = 'm-coding-std.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
46 DOCS = 'm-docs.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
47 NEWWIKI = 'm-new-wiki.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
48 DELWIKI = 'm-delete-wiki.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
49 BACKUPWIKI = 'm-backup-wiki.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
50 EXTRAS = 'm-extras.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
51 DIST = 'm-create-dist.txt'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
52 # default files used for backup and restore
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
53 BACKUP_FILENAME = os.path.normpath('wiki/backup.moin')
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
54 JUST_IN_CASE_BACKUP = os.path.normpath('wiki/deleted-backup.moin')
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
55
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
56
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
57 if os.name == 'nt':
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
58 M = 'm' # customize help to local OS
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
59 ACTIVATE = 'activate.bat & '
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
60 SEP = ' & '
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
61 WINDOWS_OS = True
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
62 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
63 M = './m'
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
64 # in terminal "source activate" works, but Ubuntu shell requires ". ./activate"
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
65 ACTIVATE = '. ./activate; '
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
66 SEP = ';'
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
67 WINDOWS_OS = False
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
68
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
69
2775
9c036e6c2265 update make.py to run all tests, including pep8 tests, in one pass with pytest 2.6.1
RogerHaase <haaserd@gmail.com>
parents: 2774
diff changeset
70 # commands that create log files
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
71 CMD_LOGS = {
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
72 'quickinstall': QUICKINSTALL,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
73 'pytest': PYTEST,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
74 # 'coding-std': CODING_STD, # not logged due to small output
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
75 'docs': DOCS,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
76 'new-wiki': NEWWIKI,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
77 'del-wiki': DELWIKI,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
78 'backup': BACKUPWIKI,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
79 'extras': EXTRAS,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
80 'dist': DIST,
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
81 }
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
82
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
83
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
84 help = """
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
85
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
86 usage: "{0} <target>" where <target> is:
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
87
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
88 quickinstall update virtual environment with required packages
2314
42d4f773ca4a rewrite requirements.rst, install.rst, and development.rst to document make.py
RogerHaase <haaserd@gmail.com>
parents: 2312
diff changeset
89 docs create moin html documentation
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
90 extras install OpenID, Pillow, pymongo, sqlalchemy, ldap, upload.py
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
91 interwiki refresh contrib/interwiki/intermap.txt (hg version control)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
92 log <target> view detailed log generated by <target>, omit to see list
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
93
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
94 new-wiki create empty wiki
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
95 sample create wiki and load sample data
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
96 restore * create wiki and restore wiki/backup.moin *option, specify file
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
97 import <dir> import a moin 1.9 wiki/data instance from <dir>
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
98
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
99 run run built-in wiki server
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
100 backup * roll 3 prior backups and create new backup *option, specify file
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
101
2580
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
102 css run Stylus and lessc to update theme CSS files
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
103 tests run tests, output goes to pytest.txt and pytestpep8.txt
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
104 coding-std correct scripts that taint the repository with trailing spaces..
2314
42d4f773ca4a rewrite requirements.rst, install.rst, and development.rst to document make.py
RogerHaase <haaserd@gmail.com>
parents: 2312
diff changeset
105 api update moin api docs (files are under hg version control)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
106 dist delete wiki data, then create distribution archive in dist/
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
107
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
108 del-all same as running the 4 del-* commands below
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
109 del-orig delete all files matching *.orig
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
110 del-pyc delete all files matching *.pyc
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
111 del-rej delete all files matching *.rej
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
112 del-wiki create a backup, then delete all wiki data
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
113 """.format(M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
114
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
115
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
116 def search_for_phrase(filename):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
117 """Search a text file for key phrases and print the lines of interest or print a count by phrase."""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
118 files = {
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
119 # filename: (list of phrases)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
120 QUICKINSTALL: ('could not find', 'error', 'fail', 'timeout', 'traceback', 'success', 'cache location', 'must be deactivated', ),
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
121 NEWWIKI: ('error', 'fail', 'timeout', 'traceback', 'success', ),
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
122 BACKUPWIKI: ('error', 'fail', 'timeout', 'traceback', 'success', ),
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
123 # use of 'error ' below is to avoid matching .../Modules/errors.o....
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
124 EXTRAS: ('error ', 'error:', 'error.', 'error,', 'fail', 'timeout', 'traceback', 'success', 'already satisfied', 'active version', 'installed', 'finished', ),
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
125 PYTEST: ('seconds =', ),
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
126 CODING_STD: ('remove trailing blanks', 'dos line endings', 'unix line endings', 'remove empty lines', ),
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
127 DIST: ('creating', 'copying', 'adding', 'hard linking', ),
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
128 DOCS: ('build finished', 'build succeeded', 'traceback', 'failed', 'error', 'usage', 'importerror', 'Exception occurred', )
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
129 }
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
130 # for these file names, display a count of occurrances rather than each found line
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
131 print_counts = (CODING_STD, DIST, )
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
132
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
133 with open(filename, "r") as f:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
134 lines = f.readlines()
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
135 name = os.path.split(filename)[1]
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
136 phrases = files[name]
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
137 counts = Counter()
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
138 for idx, line in enumerate(lines):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
139 line = line.lower()
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
140 for phrase in phrases:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
141 if phrase in line:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
142 if filename in print_counts:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
143 counts[phrase] += 1
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
144 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
145 print idx + 1, line.rstrip()
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
146 break
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
147 for key in counts:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
148 print 'The phrase "%s" was found %s times.' % (key, counts[key])
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
149
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
150
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
151 def wiki_exists():
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
152 """Return true if a wiki exists."""
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
153 return bool(glob.glob('wiki/index/_all_revs_*.toc'))
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
154
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
155
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
156 def make_wiki(command):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
157 """Process command to create a new wiki."""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
158 if wiki_exists():
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
159 print 'Error: a wiki exists, delete it and try again.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
160 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
161 print 'Output messages redirected to {0}.'.format(NEWWIKI)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
162 with open(NEWWIKI, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
163 result = subprocess.call(command, shell=True, stderr=messages, stdout=messages)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
164 if result == 0:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
165 print '\nSuccess: a new wiki has been created.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
166 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
167 print 'Important messages from %s are shown below:' % NEWWIKI
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
168 search_for_phrase(NEWWIKI)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
169 print '\nError: attempt to create wiki failed. Do "%s log new-wiki" to see complete log.' % M
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
170
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
171
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
172 def delete_files(pattern):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
173 """Recursively delete all files matching pattern."""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
174 matches = 0
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
175 for root, dirnames, filenames in os.walk(os.path.abspath(os.path.dirname(__file__))):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
176 for filename in fnmatch.filter(filenames, pattern):
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
177 os.remove(os.path.join(root, filename))
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
178 matches += 1
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
179 print 'Deleted %s files matching "%s".' % (matches, pattern)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
180
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
181
2580
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
182 def get_bootstrap_data_location():
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
183 """Return the virtualenv site-packages/xstatic/pkg/bootstrap/data location."""
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
184 command = ACTIVATE + 'python -c "from xstatic.pkg.bootstrap import BASE_DIR; print BASE_DIR"'
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
185 return subprocess.check_output(command, shell=True)
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
186
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
187
2649
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
188 def get_pygments_data_location():
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
189 """Return the virtualenv site-packages/xstatic/pkg/pygments/data location."""
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
190 command = ACTIVATE + 'python -c "from xstatic.pkg.pygments import BASE_DIR; print BASE_DIR"'
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
191 return subprocess.check_output(command, shell=True)
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
192
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
193
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
194 class Commands(object):
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
195 """Each cmd_ method processes a choice on the menu."""
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
196 def __init__(self):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
197 pass
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
198
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
199 def cmd_quickinstall(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
200 """create or update a virtual environment with the required packages"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
201 command = '{0} quickinstall.py {1}'.format(sys.executable, ' '.join(args))
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
202 print 'Running quickinstall.py... output messages redirected to {0}'.format(QUICKINSTALL)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
203 with open(QUICKINSTALL, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
204 result = subprocess.call(command, shell=True, stderr=messages, stdout=messages)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
205 if result != 0:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
206 open(QUICKINSTALL, 'a').write('Error: quickinstall passed non-zero return code: {0}'.format(result))
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
207 print 'Searching {0}, important messages are shown below... Do "{1} log quickinstall" to see complete log.\n'.format(QUICKINSTALL, M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
208 search_for_phrase(QUICKINSTALL)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
209
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
210 def cmd_docs(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
211 """create local Sphinx html documentation"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
212 command = '{0}cd docs{1} make html'.format(ACTIVATE, SEP)
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
213 print 'Creating HTML docs... output messages written to {0}.'.format(DOCS)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
214 with open(DOCS, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
215 result = subprocess.call(command, shell=True, stderr=messages, stdout=messages)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
216 print 'Searching {0}, important messages are shown below...\n'.format(DOCS)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
217 search_for_phrase(DOCS)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
218 if result == 0:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
219 print 'HTML docs successfully created in {0}.'.format(os.path.normpath('docs/_build/html'))
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
220 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
221 print 'Error: creation of HTML docs failed with return code "{0}". Do "{1} log docs" to see complete log.'.format(result, M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
222
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
223 def cmd_extras(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
224 """install optional packages: OpenID, Pillow, pymongo, sqlalchemy, ldap; and upload.py"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
225 upload = '{0} MoinMoin/script/win/wget.py https://codereview.appspot.com/static/upload.py upload.py'.format(sys.executable)
2586
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
226 packages = ['python-openid', 'pillow', 'pymongo', 'sqlalchemy', ]
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
227 if WINDOWS_OS:
2586
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
228 installer = 'easy_install --upgrade '
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
229 # TODO: "easy_install python-ldap" fails on windows. Try google: installing python-ldap in a virtualenv on windows
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
230 # or, download from http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
2586
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
231 # activate.bat
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
232 # easy_install <path to downloaded .exe file>
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
233 else:
2586
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
234 installer = 'pip install --upgrade '
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
235 packages.append('python-ldap')
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
236 command = ACTIVATE + installer + (SEP + installer).join(packages) + SEP + upload
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2580
diff changeset
237 print 'Installing {0}, upload.py... output messages written to {1}.'.format(', '.join(packages), EXTRAS)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
238 with open(EXTRAS, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
239 subprocess.call(command, shell=True, stderr=messages, stdout=messages)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
240 print 'Important messages from {0} are shown below. Do "{1} log extras" to see complete log.'.format(EXTRAS, M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
241 search_for_phrase(EXTRAS)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
242
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
243 def cmd_interwiki(self, *args):
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
244 """refresh contrib/interwiki/intermap.txt"""
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
245 print 'Refreshing {0}...'.format(os.path.normpath('contrib/interwiki/intermap.txt'))
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
246 command = '{0} MoinMoin/script/win/wget.py http://master19.moinmo.in/InterWikiMap?action=raw contrib/interwiki/intermap.txt'.format(sys.executable)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
247 subprocess.call(command, shell=True)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
248
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
249 def cmd_log(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
250 """View a log file with the default text editor"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
251
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
252 def log_help(logs):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
253 """Print list of available logs to view."""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
254 print "usage: {0} log <target> where <target> is:\n\n".format(M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
255 choices = '{0: <16}- {1}'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
256 for log in sorted(logs):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
257 if os.path.isfile(CMD_LOGS[log]):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
258 print choices.format(log, CMD_LOGS[log])
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
259 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
260 print choices.format(log, '* file does not exist')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
261
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
262 logs = set(CMD_LOGS.keys())
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
263 if args and args[0] in logs and os.path.isfile(CMD_LOGS[args[0]]):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
264 if WINDOWS_OS:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
265 command = 'start {0}'.format(CMD_LOGS[args[0]])
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
266 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
267 # .format requires {{ and }} to escape { and }
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
268 command = '${{VISUAL:-${{FCEDIT:-${{EDITOR:-less}}}}}} {0}'.format(CMD_LOGS[args[0]])
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
269 subprocess.call(command, shell=True)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
270 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
271 log_help(logs)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
272
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
273 def cmd_new_wiki(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
274 """create empty wiki"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
275 command = '{0}moin index-create -s -i'.format(ACTIVATE)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
276 print 'Creating a new empty wiki...'
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
277 make_wiki(command) # share code with loading sample data and restoring backups
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
278
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
279 def cmd_sample(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
280 """create wiki and load sample data"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
281 command = '{0}moin index-create -s -i{1} moin load --file contrib/serialized/items.moin{1} moin index-build'.format(ACTIVATE, SEP)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
282 print 'Creating a new wiki populated with sample data...'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
283 make_wiki(command)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
284
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
285 def cmd_restore(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
286 """create wiki and load data from wiki/backup.moin or user specified path"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
287 command = '{0} moin index-create -s -i{1} moin load --file %s{1} moin index-build'.format(ACTIVATE, SEP)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
288 filename = BACKUP_FILENAME
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
289 if args:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
290 filename = args[0]
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
291 if os.path.isfile(filename):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
292 command = command % filename
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
293 print 'Creating a new wiki and loading it with data from {0}...'.format(filename)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
294 make_wiki(command)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
295 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
296 print 'Error: cannot create wiki because {0} does not exist.'.format(filename)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
297
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
298 def cmd_import(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
299 """import a moin 1.9 wiki directory named dir"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
300 if args:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
301 dirname = args[0]
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
302 if os.path.isdir(dirname):
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
303 command = '{0}moin import19 -s -i --data_dir {1}'.format(ACTIVATE, dirname)
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
304 print 'Creating a new wiki populated with data from {0}...'.format(dirname)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
305 make_wiki(command)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
306 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
307 print 'Error: cannot create wiki because {0} does not exist.'.format(dirname)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
308 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
309 print 'Error: a path to the Moin 1.9 wiki/data data directory is required.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
310
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
311 def cmd_run(self, *args):
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
312 """run built-in wiki server"""
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
313 if wiki_exists():
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
314 command = '{0}moin moin {1}'.format(ACTIVATE, ' '.join(args))
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
315 try:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
316 subprocess.call(command, shell=True)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
317 except KeyboardInterrupt:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
318 pass # eliminates traceback on windows
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
319 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
320 print 'Error: a wiki must be created before running the built-in server.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
321
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
322 def cmd_backup(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
323 """roll 3 prior backups and create new wiki/backup.moin or backup to user specified file"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
324 if wiki_exists():
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
325 filename = BACKUP_FILENAME
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
326 if args:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
327 filename = args[0]
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
328 print 'Creating a wiki backup to {0}...'.format(filename)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
329 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
330 print 'Creating a wiki backup to {0} after rolling 3 prior backups...'.format(filename)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
331 b3 = BACKUP_FILENAME.replace('.', '3.')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
332 b2 = BACKUP_FILENAME.replace('.', '2.')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
333 b1 = BACKUP_FILENAME.replace('.', '1.')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
334 if os.path.exists(b3):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
335 os.remove(b3)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
336 for src, dst in ((b2, b3), (b1, b2), (BACKUP_FILENAME, b1)):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
337 if os.path.exists(src):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
338 os.rename(src, dst)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
339
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
340 command = '{0}moin save --all-backends --file {1}'.format(ACTIVATE, filename)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
341 with open(BACKUPWIKI, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
342 result = subprocess.call(command, shell=True, stderr=messages, stdout=messages)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
343 if result == 0:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
344 print 'Success: wiki was backed up to {0}'.format(filename)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
345 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
346 print 'Important messages from {0} are shown below. Do "{1} log backup" to see complete log.'.format(BACKUPWIKI, M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
347 search_for_phrase(BACKUPWIKI)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
348 print '\nError: attempt to backup wiki failed.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
349 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
350 print 'Error: cannot backup wiki because it has not been created.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
351
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
352 def cmd_css(self, *args):
2580
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
353 """run Stylus and lessc to update CSS files"""
2774
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
354 # Note: we use / below within file paths; this works in Windows XP, 2000, 7, 8
2649
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
355 bootstrap_loc = get_bootstrap_data_location().strip() + '/less'
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
356 pygments_loc = get_pygments_data_location().strip() + '/css'
2774
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
357 modernized_loc = 'MoinMoin/themes/modernized/static/css/stylus'
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
358 basic_loc = 'MoinMoin/themes/basic/static/custom-less'
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
359
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
360 print 'Running lessc to create normalize.css for modernized theme...'
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
361 command = 'lessc {0}/normalize.less > {1}/normalize.css'.format(bootstrap_loc, modernized_loc)
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
362 result = subprocess.call(command, shell=True)
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
363 if result == 0:
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
364 print 'Success: normalize.css created for modernized theme.'
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
365 else:
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
366 print 'Error: creation of normalize.css failed, see error messages above.'
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
367
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
368 print 'Running Stylus to update Modernized theme CSS files...'
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
369 command = 'cd {0}{1}stylus --include {2} --include-css --compress < theme.styl > ../theme.css'.format(modernized_loc, SEP, pygments_loc)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
370 result = subprocess.call(command, shell=True)
2773
c860300a60c9 remove foobar theme and delete supporting code in common.js and make.py
RogerHaase <haaserd@gmail.com>
parents: 2681
diff changeset
371 if result == 0:
c860300a60c9 remove foobar theme and delete supporting code in common.js and make.py
RogerHaase <haaserd@gmail.com>
parents: 2681
diff changeset
372 print 'Success: Modernized CSS files updated.'
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
373 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
374 print 'Error: stylus failed to update css files, see error messages above.'
2681
4918721350e1 Solves issue #425
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
375 # stylus adds too many blank lines at end of modernized theme.css, fix it by running coding_std against css directory
2610
3334da53527e prevent stylus vs. coding-std conflict on modernized common.css
RogerHaase <haaserd@gmail.com>
parents: 2586
diff changeset
376 command = 'python contrib/pep8/coding_std.py MoinMoin/themes/modernized/static/css'
3334da53527e prevent stylus vs. coding-std conflict on modernized common.css
RogerHaase <haaserd@gmail.com>
parents: 2586
diff changeset
377 result = subprocess.call(command, shell=True)
3334da53527e prevent stylus vs. coding-std conflict on modernized common.css
RogerHaase <haaserd@gmail.com>
parents: 2586
diff changeset
378 if result != 0:
3334da53527e prevent stylus vs. coding-std conflict on modernized common.css
RogerHaase <haaserd@gmail.com>
parents: 2586
diff changeset
379 print 'Error: failure running coding_std.py against modernized css files'
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
380
2580
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
381 print 'Running lessc to update Basic theme CSS files...'
2649
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
382 if WINDOWS_OS:
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
383 data_loc = '{0};{1}'.format(bootstrap_loc, pygments_loc)
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
384 else:
82ffb3f45eed Added pygments css classes in basic theme by installing pygments Xstatic package in the virtual environment and importing css files from there. Also removed the manually added pygments definitions in the foobar and modernized themes and imported pygments css in the same wasy as done in the basic theme.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2610
diff changeset
385 data_loc = '{0}:{1}'.format(bootstrap_loc, pygments_loc)
2651
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2649
diff changeset
386 include = '--include-path=' + data_loc
2774
bf6fcb963d32 fix #428 change modernized reset.css to normalize.css bundled with bootstrap
RogerHaase <haaserd@gmail.com>
parents: 2773
diff changeset
387 command = 'cd {0}{1}lessc {2} theme.less ../css/theme.css'.format(basic_loc, SEP, include)
2580
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
388 result = subprocess.call(command, shell=True)
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
389 if result == 0:
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
390 print 'Success: Basic theme CSS files updated.'
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
391 else:
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
392 print 'Error: Basic theme CSS files update failed, see error messages above.'
fb44a83e9720 add compilation of basic theme CSS files to make.py; requires change to xstatic bootstrap package
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
393
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
394 def cmd_tests(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
395 """run tests, output goes to pytest.txt and pytestpep8.txt"""
2775
9c036e6c2265 update make.py to run all tests, including pep8 tests, in one pass with pytest 2.6.1
RogerHaase <haaserd@gmail.com>
parents: 2774
diff changeset
396 print 'Running tests... output written to {0}.'.format(PYTEST)
9c036e6c2265 update make.py to run all tests, including pep8 tests, in one pass with pytest 2.6.1
RogerHaase <haaserd@gmail.com>
parents: 2774
diff changeset
397 command = '{0}py.test --pep8 > {1} 2>&1'.format(ACTIVATE, PYTEST)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
398 result = subprocess.call(command, shell=True)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
399 print 'Summary message from {0} is shown below. Do "{1} log pytest" to see complete log.'.format(PYTEST, M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
400 search_for_phrase(PYTEST)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
401
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
402 def cmd_coding_std(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
403 """correct scripts that taint the HG repository and clutter subsequent code reviews"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
404 print 'Checking for trailing blanks, DOS line endings, Unix line endings, empty lines at eof...'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
405 command = '%s contrib/pep8/coding_std.py' % sys.executable
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
406 subprocess.call(command, shell=True)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
407
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
408 def cmd_api(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
409 """update Sphinx API docs, these docs are under hg version control"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
410 print 'Refreshing api docs...'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
411 if WINDOWS_OS:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
412 # after update, convert DOS line endings to unix
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
413 command = '{0}sphinx-apidoc -f -o docs/devel/api MoinMoin & {1} MoinMoin/script/win/dos2unix.py docs/devel/api'.format(ACTIVATE, sys.executable)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
414 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
415 command = '{0}sphinx-apidoc -f -o docs/devel/api MoinMoin'.format(ACTIVATE)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
416 result = subprocess.call(command, shell=True)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
417
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
418 def cmd_dist(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
419 """create distribution archive in dist/"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
420 print 'Deleting wiki data, then creating distribution archive in /dist, output written to {0}.'.format(DIST)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
421 self.cmd_del_wiki(*args)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
422 command = '{0} setup.py sdist'.format(sys.executable)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
423 with open(DIST, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
424 result = subprocess.call(command, shell=True, stderr=messages, stdout=messages)
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
425 print 'Summary message from {0} is shown below:'.format(DIST)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
426 search_for_phrase(DIST)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
427 if result == 0:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
428 print 'Success: a distribution archive was created in {0}.'.format(os.path.normpath('/dist'))
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
429 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
430 print 'Error: create dist failed with return code = {0}. Do "{1} log dist" to see complete log.'.format(result, M)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
431
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
432 def cmd_del_all(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
433 """same as running the 4 del-* commands below"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
434 self.cmd_del_orig(*args)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
435 self.cmd_del_pyc(*args)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
436 self.cmd_del_rej(*args)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
437 self.cmd_del_wiki(*args)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
438
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
439 def cmd_del_orig(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
440 """delete all files matching *.orig"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
441 delete_files('*.orig')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
442
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
443 def cmd_del_pyc(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
444 """delete all files matching *.pyc"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
445 delete_files('*.pyc')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
446
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
447 def cmd_del_rej(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
448 """delete all files matching *.rej"""
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
449 delete_files('*.rej')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
450
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
451 def cmd_del_wiki(self, *args):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
452 """create a just-in-case backup, then delete all wiki data"""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
453 command = '{0}moin save --all-backends --file {1}'.format(ACTIVATE, JUST_IN_CASE_BACKUP)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
454 if wiki_exists():
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
455 print 'Creating a backup named {0}; then deleting all wiki data and indexes...'.format(JUST_IN_CASE_BACKUP)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
456 with open(DELWIKI, 'w') as messages:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
457 result = subprocess.call(command, shell=True, stderr=messages, stdout=messages)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
458 if result != 0:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2314
diff changeset
459 print 'Error: backup failed with return code = {0}. Complete log is in {1}.'.format(result, DELWIKI)
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
460 # destroy wiki even if backup fails
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
461 if os.path.isdir('wiki/data') or os.path.isdir('wiki/index'):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
462 shutil.rmtree('wiki/data')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
463 shutil.rmtree('wiki/index')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
464 print 'Wiki data successfully deleted.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
465 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
466 print 'Wiki data not deleted because it does not exist.'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
467
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
468
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
469 if __name__ == '__main__':
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
470 # create a set of valid menu choices
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
471 commands = Commands()
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
472 choices = set()
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
473 names = dir(commands)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
474 for name in names:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
475 if name.startswith('cmd_'):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
476 choices.add(name)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
477
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
478 if len(sys.argv) == 1 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
479 print help
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
480 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
481 if sys.argv[1] != 'quickinstall' and not (os.path.isfile('activate') or os.path.isfile('activate.bat')):
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
482 print 'Error: files created by quickinstall are missing, run "%s quickinstall" and try again.' % M
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
483 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
484 choice = 'cmd_%s' % sys.argv[1]
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
485 choice = choice.replace('-', '_')
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
486 if choice in choices:
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
487 choice = getattr(commands, choice)
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
488 choice(*sys.argv[2:])
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
489 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
490 print help
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents:
diff changeset
491 print 'Error: unknown menu selection "%s"' % sys.argv[1]