Project

Profile

Help

Revision e379f35a

IDe379f35a15956204f09aa593979fe0a0186cf56e
Parent 4e639788
Child d97851dd, 76dc4f8b

Added by Vincent Le Goff 6 months ago

Update the upload tool

View differences:

tools/upload_build.py
13 13
import os
14 14
import re
15 15
import sys
16
import urllib2
16
from urllib import request
17 17

  
18 18
from redminelib import Redmine
19 19
from redminelib.exceptions import ResourceNotFoundError
......
33 33
# Check that the file exists
34 34
path = os.path.abspath("../src/build/CocoMUD.zip")
35 35
if not os.path.exists(path):
36
    print "The file {} cannot be found.".format(path)
36
    print("The file {} cannot be found.".format(path))
37 37
    sys.exit(1)
38 38

  
39 39
# Then upload this file
40
print "Retrieving the Download wiki page on 'cocomud-client'..."
40
print("Retrieving the Download wiki page on 'cocomud-client'...")
41 41
page = redmine.wiki_page.get("Download", project_id="cocomud-client")
42
print "Uploading {}...".format(path)
42
print("Uploading {}...".format(path))
43 43
text = page.text
44 44
page.uploads = [{"path": path, "filename": "CocoMUD.zip"}]
45 45
page.text = text
46
print "Saving the page...", page.save()
46
print("Saving the page...", page.save())
47 47

  
48 48
# Get the new resource URL
49 49
url = list(page.attachments)[-1].content_url
50 50

  
51 51
# Retrieve the version number
52
with open("../src/version.py") as file:
52
with open("../src/version.py", encoding="utf-8") as file:
53 53
    content = file.read()
54 54

  
55 55
version = content.partition("=")[2].strip()
......
64 64
    except ResourceNotFoundError:
65 65
        pass
66 66
    else:
67
        print "Updating the Download page for the {} project...".format(
68
                identifier)
67
        print("Updating the Download page for the {} project...".format(
68
                identifier))
69 69
        text = page.text
70 70
        text = re.sub(r"https\://cocomud\.plan\.io/attachments/" \
71 71
                r"download/\d+/CocoMUD\.zip", url, text)
......
73 73
        page.text = text
74 74
        success = page.save()
75 75
        if success:
76
            print "Correctly saved the wiki page."
76
            print("Correctly saved the wiki page.")
77 77
        else:
78
            print "Error while saving the wiki page."
78
            print("Error while saving the wiki page.")
79 79

  
80 80
# Update the build information in the custom field
81 81
build = dumps({version: {"windows": url}})
82
print "Updating the custom field"
82
print("Updating the custom field")
83 83
redmine.project.update(resource_id=2,
84 84
        custom_fields=[{"id": 3, "value": build}])
85
print "URL", url
85
print("URL", url)

Also available in: Unified diff