-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathupdstory.py
109 lines (91 loc) · 5.67 KB
/
updstory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
#################################################################################################
#
# upstory.py - example of how to effect an update to an existing Story
# specifically changing the Description to include the
# CKEditor markup for links
#
USAGE = """\
Usage: python updstory.py <StoryID> <attribute> <value>
"""
#################################################################################################
import sys, os
from pyral import Rally, rallyWorkset, RallyRESTAPIError
#################################################################################################
errout = sys.stderr.write
#################################################################################################
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, user, password, apikey, workspace, project = rallyWorkset(options)
workspace = 'Yeti Rally Workspace'
project = 'Danish Cookies'
rally = Rally(server, user, password, apikey=apikey,
workspace=workspace, project=project,
isolated_workspace=True)
#rally.enableLogging("rally.history.updstory")
if not args:
print(USAGE)
sys.exit(1)
if len(args) == 3:
story_id , attribute, value = args[:3]
else:
story_id = args[0]
attribute = 'Description'
value = """
<p><a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">[https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg]</a></p>
<p><a href="https://ckeditor.com/docs/ckeditor5/latest/assess/img/food_2.jpg">finiky ediblus</a></p>
<p><a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">glorious CKEditor food pic</a></p>
<p><a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">small image of food plate</a></p>
<p> </p>
<p><a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg</a></p>
<p> </p>
<p>[funky chicken|<a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">assets</a>]</p>
<p> </p>
<p>regular text</p
><p> </p>
<p>[<a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">jones boys|https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg</a>]</p>
<p> </p>
<p><a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">hibeam</a></p>
<p> </p>
"""
value = """
<p><span style="color:#4c9aff;">Huubina treandle korz</span></p>
<p> </p> <p><i>Links</i><br>Link to giphy <a href="https://giphy.com|smart-link">https://giphy.com</a></p>
<p> </p> <p>on to <a href="http://www.windy.com|smart-link">http://www.windy.com</a></p>
<p> </p> <p><i>Images</i><br>Uploaded</p>
<hr>
<figure class="image image_resized" style="width:80%"><img src="/slm/attachment/730942835535/moab-winter-dusting.jpg"></figure>
<hr>
<p> </p> <p><img src="bff5de03-823d-41ab-a448-3be70f94ec23#media-blob-url=true&id=cb54963b-2da1-4cf6-8642-1a2d7c815ab4&collection=upload-user-collection-92668751&contextId=12489&width=226&height=144&alt=|width=777,height=496" alt="bff5de03-823d-41ab-a448-3be70f94ec23"></p>
<p> </p> <h3>Just some verbal spillage for testing</h3><p> </p> <p>Merlin <s>commanded</s> advised me to tell you to give-me-a-break whenever i tell you to <s>stfu</s> put a brick in your <s>piehole</s> mouth, go-to-he-double-hockey-sticks doofus and <s>donty never sully my palace again</s>!</p>
<p> </p> <p>Linked<br><a href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg">https://ckeditor.com/docs/ckeditor5/latest/assets/img/food_2.jpg</a></p>
<p> </p> <p><img src="alta-harbor.jpg|width=57600,height=43200" alt="alta-harbor.jpg"></p>
<p> </p> <p>Isn’t Alta harbor cold and beautiful?</p>
<p> </p> <p>Can’t anybody figure out how to get a table to be obtuse to the max?</p>
<p> </p> <figure class="table"><table><thead><tr><th><strong>manufacturer</strong></th><th><strong>year</strong></th><th><strong>country</strong></th></tr></thead><tbody><tr><td>mercedes</td><td>1965</td><td>germany</td></tr><tr><td>toyota</td><td>2003</td><td>japan</td></tr><tr><td>fored</td><td>2010</td><td>usa</td></tr></tbody></table></figure><p> </p> <p>|_.*Too Tall to think*|<br>F</p>
<p> </p> <p><figure class="image"><img src="/slm/attachment/730939833657/inxs-devil-inside.jpg"></figure></p>
<p> </p> <p>never let me down…</p>
<p> </p> <p> </p> <figure class="image"><img src="/slm/attachment/730939835245/alta-harbor.jpg"></figure>
"""
target_oid = None
response = rally.get('Story', fetch="ObjectID,Name,FormattedID,Project,Description,Tags",
query=f"FormattedID = {story_id}", isolated_workspace=True)
story = response.next()
print(f'target Story OID value: {story.oid}')
upd_info = {"FormattedID" : story_id,
attribute : value,
}
print(upd_info)
try:
story = rally.update('Story', upd_info)
except RallyRESTAPIError as exc:
sys.stderr.write(f'ERROR: {str(exc)}')
sys.exit(2)
print("Story updated")
print(f'FormattedID: {story.FormattedID} ObjectID: {story.oid} Name: {story.Name} Project: {story.Project.Name}')
#################################################################################################
#################################################################################################
if __name__ == '__main__':
main(sys.argv[1:])
sys.exit(0)