-
Notifications
You must be signed in to change notification settings - Fork 114
/
GoToMeetingURLProvider.py
executable file
·76 lines (63 loc) · 2.43 KB
/
GoToMeetingURLProvider.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
#!/usr/bin/env python
#
# Copyright 2015 Elliot Jordan
# Based on original processor by Nick Gamewell
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re
import urllib2
import json
from autopkglib import Processor, ProcessorError
__all__ = ["GoToMeetingURLProvider"]
BASE_URL = "https://p5.osdimg.com/g2mupdater/live/config.json"
class GoToMeetingURLProvider(Processor):
"""Provides a download URL for the latest GoToMeeting release."""
input_variables = {
"base_url": {
"required": False,
"description": "Default is %s" % BASE_URL
}
}
output_variables = {
"url": {
"description": "URL to the latest GoToMeeting release."
},
"build": {
"description": "Build number of the latest GoToMeeting release."
}
}
description = __doc__
def get_g2m_url(self, base_url):
try:
jsonData = json.loads(urllib2.urlopen(base_url).read())
return jsonData['activeBuilds'][
len(jsonData['activeBuilds']) - 1]['macDownloadUrl']
except BaseException as err:
raise Exception("Can't read %s: %s" % (base_url, err))
def get_g2m_build(self, base_url):
try:
jsonData = json.loads(urllib2.urlopen(base_url).read())
return str(jsonData['activeBuilds'][
len(jsonData['activeBuilds']) - 1]['buildNumber'])
except BaseException as err:
raise Exception("Can't read %s: %s" % (base_url, err))
def main(self):
"""Find and return a download URL"""
base_url = self.env.get("base_url", BASE_URL)
self.env["url"] = self.get_g2m_url(base_url)
self.output("Found URL %s" % self.env["url"])
self.env["build"] = self.get_g2m_build(base_url)
self.output("Build number %s" % self.env["build"])
if __name__ == "__main__":
processor = GoToMeetingURLProvider()
processor.execute_shell()