Difference between revisions of "Import Lessons from test wiki"
From forestDSS
SeanGordon (Talk | contribs) m |
SeanGordon (Talk | contribs) m (Text replace - "Has issue priority=high" to "Has issue priority=1-high") |
||
(8 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
|Has responsible person or organization=Sean (help from Dominique / Jussi) | |Has responsible person or organization=Sean (help from Dominique / Jussi) | ||
|Has issue description=Some Lessons on the test wiki have been changed since the last import. Need to re-import. | |Has issue description=Some Lessons on the test wiki have been changed since the last import. Need to re-import. | ||
− | |Has issue solution= | + | |Has issue solution=1. Delete current Lessons on public wiki |
− | * | + | *Problem: For some pages, the page_touched property was ‘False’ |
− | # Re-import lessons from test wiki | + | *I’m not sure why this would be, since creating the page should generate a page_touched date-time |
− | |Has issue priority=high | + | *This caused an error, since the mwclient.page.py script expects all page_touched values (if present) to be a date-time |
− | | | + | *I changed a few lines in mwclient.page.py to handle the ‘False’ value correctly |
+ | <nowiki> | ||
+ | if info.get('touched'): | ||
+ | touch = info.get('touched') | ||
+ | else: | ||
+ | touch = '0000-00-00T00:00:00Z' | ||
+ | self.touched = client.parse_timestamp(touch) | ||
+ | ##self.touched = client.parse_timestamp(info.get('touched', '0000-00-00T00:00:00Z')) | ||
+ | </nowiki> | ||
+ | |||
+ | 2. Re-import lessons from test wiki | ||
+ | * Done | ||
+ | |Has issue priority=1-high | ||
+ | |Has task status=Completed | ||
}} | }} | ||
− | <nowiki> | + | <nowiki> |
import sys | import sys | ||
sys.path.append('mwclient') | sys.path.append('mwclient') | ||
− | |||
import mwclient | import mwclient | ||
+ | import time | ||
+ | |||
+ | print __file__ + ' ' + time.asctime( time.localtime(time.time()) ) | ||
+ | print 'Transferring...' | ||
+ | |||
+ | filter = 'Category:Lesson' | ||
− | + | exclude_lessons = [] | |
+ | ##exclude_lessons = ['Brazil', 'Actor Network Theory', 'Using GISCAME', 'Assessing forest functions', 'Modular Forest Management'] | ||
− | + | site1 = mwclient.Site('test.forsys.siwawa.org','/wiki/') | |
− | + | site1.login('forsys', 'forsys1') | |
− | + | site2 = mwclient.Site('fp0804.emu.ee','/wiki/') | |
− | + | site2.login('SeanGordon', '4other') | |
− | for | + | for page1 in site1.Pages[filter]: |
− | + | pagename = page1.page_title | |
− | print | + | print pagename |
− | + | text = page1.edit() | |
− | + | page2 = site2.Pages[pagename] | |
+ | page2.save(text,summary='Seans automated transfer') | ||
+ | ## revisions = lessonpage.revisions() | ||
+ | ## for rev in revisions: | ||
+ | ## print ' comment: ' + rev['comment'] | ||
+ | ## | ||
+ | ## if rev['comment'][:4] == 'Sean': | ||
+ | ## print ' - deleting' | ||
+ | ## lessonpage.delete(reason='Seans automated replacement') | ||
+ | ## break | ||
+ | ## print | ||
print "DONE" | print "DONE" | ||
</nowiki> | </nowiki> |
Latest revision as of 00:22, 7 September 2013
Has issue type | Suggestion |
---|---|
Has author | Sean |
Has responsible person or organization | Sean (help from Dominique / Jussi) |
Has issue description | Some Lessons on the test wiki have been changed since the last import. Need to re-import. |
Has issue solution | The given value was not understood. |
Has issue priority | 1-high |
Has task status | Completed |
import sys sys.path.append('mwclient') import mwclient import time print __file__ + ' ' + time.asctime( time.localtime(time.time()) ) print 'Transferring...' filter = 'Category:Lesson' exclude_lessons = [] ##exclude_lessons = ['Brazil', 'Actor Network Theory', 'Using GISCAME', 'Assessing forest functions', 'Modular Forest Management'] site1 = mwclient.Site('test.forsys.siwawa.org','/wiki/') site1.login('forsys', 'forsys1') site2 = mwclient.Site('fp0804.emu.ee','/wiki/') site2.login('SeanGordon', '4other') for page1 in site1.Pages[filter]: pagename = page1.page_title print pagename text = page1.edit() page2 = site2.Pages[pagename] page2.save(text,summary='Seans automated transfer') ## revisions = lessonpage.revisions() ## for rev in revisions: ## print ' comment: ' + rev['comment'] ## ## if rev['comment'][:4] == 'Sean': ## print ' - deleting' ## lessonpage.delete(reason='Seans automated replacement') ## break ## print print "DONE"