Last change
on this file since 1181 was 1169, checked in by iritscen, 3 years ago |
ValBot: Reorganized files. Updated docs with more helpful information.
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | IFS="
|
---|
4 | "
|
---|
5 |
|
---|
6 | CORE="/path/to/Pywikibot/core"
|
---|
7 | SUMMARY="changing link from http->https"
|
---|
8 | RATE=6
|
---|
9 | FIX_START=551
|
---|
10 | FIX_END=650
|
---|
11 |
|
---|
12 | cd "$CORE"
|
---|
13 | if [ ! -f "pwb.py" ]; then
|
---|
14 | echo "drive_https_upgrade.sh: Can't launch Pywikibot!"
|
---|
15 | exit
|
---|
16 | fi
|
---|
17 |
|
---|
18 | echo "drive_https_upgrade.sh: Starting at fix $FIX_START..."
|
---|
19 |
|
---|
20 | FIX_CUR=0
|
---|
21 | LAST_RUN=0
|
---|
22 | for THE_LINE in `cat "/path/to/ValExtLinks report.txt"`; do
|
---|
23 | if [[ $THE_LINE =~ .*http-\>https.* ]]; then
|
---|
24 | let FIX_CUR+=1
|
---|
25 | if [ $FIX_CUR -lt $FIX_START ]; then
|
---|
26 | continue
|
---|
27 | fi
|
---|
28 | if [ $FIX_CUR -gt $FIX_END ]; then
|
---|
29 | echo "drive_https_upgrade.sh: Stopped after fix $FIX_END."
|
---|
30 | exit
|
---|
31 | fi
|
---|
32 |
|
---|
33 | # Wait for rate limit to expire if we have run the Python script before in this session
|
---|
34 | if [ $LAST_RUN -gt 0 ]; then
|
---|
35 | CUR_TIME=$(date +%s)
|
---|
36 | WAIT_REMAINDER=$(($RATE - $CUR_TIME + $LAST_RUN))
|
---|
37 | if [ $WAIT_REMAINDER -gt 0 ]; then
|
---|
38 | echo "drive_https_upgrade.sh: Waiting $WAIT_REMAINDER second(s)."
|
---|
39 | sleep $WAIT_REMAINDER
|
---|
40 | fi
|
---|
41 | fi
|
---|
42 | ON_PAGE=${THE_LINE#*page \'}
|
---|
43 | ON_PAGE=${ON_PAGE%%\'*}
|
---|
44 | FROM_LINK=${THE_LINE#*URL \'}
|
---|
45 | FROM_LINK=${FROM_LINK%%\'*}
|
---|
46 | TO_LINK=${THE_LINE%\'*}
|
---|
47 | TO_LINK=${TO_LINK##*\'}
|
---|
48 | LAST_RUN=$(date +%s)
|
---|
49 | python pwb.py replace -page:"$ON_PAGE" "$FROM_LINK" "$TO_LINK" -summary:"$SUMMARY" -always
|
---|
50 | fi
|
---|
51 | done
|
---|
Note:
See
TracBrowser
for help on using the repository browser.