-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Archive additional wiki resources (WIP) #223
Open
PiRSquared17
wants to merge
2
commits into
WikiTeam:master
Choose a base branch
from
PiRSquared17:save-resources
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1171,6 +1171,12 @@ def getParameters(params=[]): | |
help='store only the current version of pages') | ||
groupDownload.add_argument( | ||
'--images', action='store_true', help="generates an image dump") | ||
groupDownload.add_argument( | ||
'--resources', | ||
default="html", | ||
choices=["html","dir","warc"], | ||
help="""generate a backup of Main Page as HTML or with resources (CSS, etc.). The dir | ||
and warc options require wget and may leave your IP address in the requisites.""") | ||
groupDownload.add_argument( | ||
'--namespaces', | ||
metavar="1,2,3", | ||
|
@@ -1200,7 +1206,7 @@ def getParameters(params=[]): | |
sys.exit(1) | ||
|
||
# No download params and no meta info params? Exit | ||
if (not args.xml and not args.images) and \ | ||
if (not args.xml and not args.images and args.resources == 'html') and \ | ||
(not args.get_wiki_engine): | ||
print 'ERROR: Use at least one download param or meta info param' | ||
parser.print_help() | ||
|
@@ -1335,6 +1341,7 @@ def getParameters(params=[]): | |
'xml': args.xml, | ||
'namespaces': namespaces, | ||
'exnamespaces': exnamespaces, | ||
'resources': args.resources, | ||
'path': args.path or '', | ||
'cookies': args.cookies or '', | ||
'delay': args.delay | ||
|
@@ -1641,7 +1648,19 @@ def saveSpecialVersion(config={}, session=None): | |
|
||
def saveIndexPHP(config={}, session=None): | ||
""" Save index.php as .html, to preserve license details available at the botom of the page """ | ||
|
||
escaped_index = "'" + config['index'].replace("'", "'\\''") + "'" | ||
escaped_path = "'" + (config['path'] + '/requisites').replace("'", "'\\''") + "'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use subprocess.check_call? This seems simple enough a command, should work I think. |
||
wget_dir = 'wget -e robots=off -p -k -H -nd -P %s --restrict-file-names=windows' | ||
wget_dir %= escaped_path | ||
wget_warc = wget_dir + ' --warc-file=%s' % escaped_path | ||
if config['resources'] == 'warc': | ||
print 'Downloading index.php (Main Page) with all resources to requisites and requisites.warc.gz' | ||
os.system(wget_warc + ' ' + escaped_index) | ||
return | ||
if config['resources'] == 'dir': | ||
print 'Downloading index.php (Main Page) with all resources to requisites' | ||
os.system(wget_dir + ' ' + escaped_index) | ||
return | ||
if os.path.exists('%s/index.html' % (config['path'])): | ||
print 'index.html exists, do not overwrite' | ||
else: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept html as the default though (the same as the current version which saves only index.html). This is because the other settings don't remove the IP address (yet).