Browse code

Adding license agreement screen in the installer

Mahmoud Bassiouny authored on 2015/04/17 15:41:53
Showing 5 changed files
... ...
@@ -13,6 +13,7 @@ from installer import Installer
13 13
 from windowstringreader import WindowStringReader
14 14
 from jsonwrapper import JsonWrapper
15 15
 from selectdisk import SelectDisk
16
+from license import License
16 17
 
17 18
 class IsoInstaller(object):
18 19
 
... ...
@@ -38,6 +39,8 @@ class IsoInstaller(object):
38 38
 
39 39
         self.install_config = {}
40 40
 
41
+        license_agreement = License(self.maxy, self.maxx)
42
+
41 43
         # skip the disk selection and partitioning if we are running with conf file in test environment.
42 44
         if local_install == True:
43 45
             # Read the conf file
... ...
@@ -73,6 +76,7 @@ class IsoInstaller(object):
73 73
                         #(disk_partitioner.display, True),
74 74
                         (select_disk.display, True)
75 75
                     ] + items
76
+        items = [(license_agreement.display, False)] + items
76 77
 
77 78
         index = 0
78 79
         params = None
79 80
new file mode 100644
... ...
@@ -0,0 +1,49 @@
0
+#! /usr/bin/python2
1
+#
2
+#    Copyright (C) 2015 vmware inc.
3
+#
4
+#    Author: Mahmoud Bassiouny <mbassiouny@vmware.com>
5
+
6
+from window import Window
7
+from actionresult import ActionResult
8
+from textpane import TextPane
9
+
10
+class License(object):
11
+    def __init__(self,  maxy, maxx):
12
+        self.maxx = maxx
13
+        self.maxy = maxy
14
+        self.win_width = maxx - 4
15
+        self.win_height = maxy - 4
16
+
17
+        self.win_starty = (self.maxy - self.win_height) / 2
18
+        self.win_startx = (self.maxx - self.win_width) / 2
19
+
20
+        self.text_starty = self.win_starty + 4
21
+        self.text_height = self.win_height - 6
22
+        self.text_width = self.win_width - 6
23
+
24
+        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Welcome to the Photon installer', False)
25
+
26
+    def display(self, params):
27
+        accept_decline_items =  [
28
+                                    ('<Accept>', self.accept_function),
29
+                                    ('<Cancel>', self.exit_function)
30
+                                ]
31
+
32
+        title = 'VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT'
33
+        self.window.addstr(0, (self.win_width - len(title)) / 2, title)
34
+        self.text_pane = TextPane(self.text_starty, self.maxx, self.text_width, "license.txt", self.text_height, accept_decline_items)
35
+
36
+        self.window.set_action_panel(self.text_pane)
37
+
38
+        return self.window.do_action()
39
+
40
+
41
+    def accept_function(self):
42
+        return ActionResult(True, None)
43
+
44
+    def exit_function(self):
45
+        exit(0)
46
+
47
+
48
+
0 49
new file mode 100644
... ...
@@ -0,0 +1,31 @@
0
+Notice to User: This Technology Preview License Agreement (the "Agreement") is a CONTRACT between you (either an individual or a single entity) ("you" or "Licensee") and VMware, Inc. ("VMware"), which covers your use of the Technology Preview Software (as defined below). If you do not agree to the terms of this Agreement, then do not install or use the Technology Preview Software. By explicitly accepting this Agreement, however, or by installing, copying, downloading, accessing, or otherwise using the Technology Preview Software, you are acknowledging and agreeing to be bound by the following terms.
1
+
2
+1.    DEFINITIONS. (a) "Technology Preview Software" means the version of VMware's software, in object form only, excluding any Open Source Software provided with the such software, and the media and Documentation provided by VMware to Licensee for which Licensee is granted a use license pursuant to this Agreement. (b) "Documentation" means the printed and online written reference material furnished to Licensee in conjunction with the Technology Preview Software, including, without limitation, instructions, testing guidelines, and end user guides. (c) "Intellectual Property Rights" shall mean all intellectual property rights, including, without limitation, patent, copyright, trademark, and trade secret. (d) "Open Source Software" means various open source software components provided with the Technology Preview Software that are licensed to you under the terms of the applicable license agreements included with such open source software components or other materials for the Technology Preview Software. (e) "Updates" means a modification, error correction, bug fix, new release, or other update to or for the Technology Preview Software.
3
+
4
+2.    LICENSE GRANT, USE AND OWNERSHIP.
5
+
6
+    (a) Limited License. Subject to the terms and conditions of this Agreement, VMware grants to Licensee a non-exclusive, non-transferable, worldwide license pursuant to the GNU General Public License version 2 (i) to use the Technology Preview Software in accordance with the Documentation, (ii) to use the Documentation provided with the Technology Preview Software in support of Licensee's authorized use of the Technology Preview Software, and (iii) to copy the Technology Preview Software for archival or backup purposes, provided that all titles and trademarks, copyright, and restricted rights notices are reproduced on such copies.
7
+
8
+    (b) Evaluation Feedback. The purpose of this limited license is the testing and evaluation of the Technology Preview Software as set forth above. In furtherance of this purpose, Licensee may provide feedback to VMware concerning the functionality and performance of the Technology Preview Software from time to time including, without limitation, identifying potential errors and improvements. Notwithstanding the foregoing, prior to Licensee disclosing to VMware any information under this Agreement that Licensee considers proprietary or confidential, Licensee shall obtain VMware's prior written approval to disclose such information to VMware, and without such prior written approval from VMware, Licensee shall not disclose any such information to VMware. VMware may use feedback to improve or enhance its products and, accordingly, you hereby grant to VMware a non-exclusive, perpetual, irrevocable, royalty-free, transferable, worldwide right and license, with the right to sublicense, to use, reproduce, disclose, distribute, perform, display, modify, prepare derivative works of and otherwise exploit the feedback and other information without restriction in any manner now known or in the future conceived and to make, use, sell, offer to sell, import and export any product or service that incorporates the feedback and other information.
9
+
10
+    (c) Ownership. VMware and other licensors shall own and retain all right, title and interest in and to the Intellectual Property Rights in the Technology Preview Software, subject only to the limited license expressly set forth in Section 2(a) hereof. Licensee does not acquire any other rights, express or implied, in the Technology Preview Software. The "VMware" trademark is a registered trademark of VMware in the U.S. and other countries. The "Photon" trademark and logo are pending registration in the U.S. Licensee shall not distribute the Technology Preview Software or its components using VMWare's trademarks. Licensee may commercially redistribute the Technology Preview Software only if (a) Licensee has entered into a separate written agreement with VMware authorizing commercial redistribution, or (b) Licensee has removed all occurrences of the VMware trademarks in the Technology Preview Software. ALL RIGHTS NOT EXPRESSLY GRANTED HEREUNDER ARE RESERVED TO VMWARE.
11
+
12
+    (d) No Support Services. VMware is under no obligation to support the Technology Preview Software in any way or to provide any Updates to Licensee. In the event VMware, in its sole discretion, supplies any Update to Licensee, the Update shall be deemed Technology Preview Software under this Agreement and shall be subject to the terms and conditions of this Agreement.
13
+
14
+    (e) Third-Party Software. The Technology Preview Software may enable a computer to run instances of third-party application programs. Licensee acknowledges that Licensee is responsible for obtaining any licenses necessary to operate any third-party software, including application programs.
15
+
16
+    (f) Open Source Software. Except for Sections 4, 5 and 6 the terms and conditions of this Agreement shall not apply to any Open Source Software accompanying the Technology Preview Software. Any such Open Source Software is provided under the terms of the open source license agreement or copyright notice accompanying such Open Source Software or in the open source licenses file accompanying the Technology Preview Software.
17
+
18
+3.    TERM AND TERMINATION. Licensee's rights with respect to the Technology Preview Software will terminate upon termination by VMware, in its sole discretion, of Licensee's rights with respect to the Technology Preview Software provided under this Agreement upon notice to Licensee. Upon any termination of rights with respect to the Technology Preview Software under this Agreement, the rights and licenses granted to Licensee under this Agreement shall immediately terminate, and Licensee shall immediately cease using, and will destroy or render practically inaccessible the Technology Preview Software, Documentation, and all other tangible items in Licensee's possession or control that contain Confidential Information. The rights and obligations of the parties set forth in Sections 2(b), 2(c), 2(d), 2(e), 2(f), 2(g), 3, 4, 5 and 6 shall survive termination of this Agreement for any reason.
19
+
20
+4.    LIMITATION OF LIABILITY. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE IS PROVIDED WITHOUT CHARGE FOR LIMITED EVALUATION PURPOSES. ACCORDINGLY, THE TOTAL LIABILITY OF VMWARE AND ITS LICENSORS ARISING OUT OF OR RELATED TO THIS AGREEMENT SHALL NOT EXCEED US$100.00. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT SHALL VMWARE OR ITS LICENSORS HAVE LIABILITY FOR ANY INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY (INCLUDING WITHOUT LIMITATION, TORT, STATUTE, CONTRACT OR OTHER), EVEN IF VMWARE AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
21
+
22
+5.    WARRANTY DISCLAIMER. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE, OPEN SOURCE SOFTWARE, DOCUMENTATION, AND ANY UPDATES MAY CONTAIN ERRORS AND ARE PROVIDED FOR LIMITED EVALUATION ONLY. THE TECHNOLOGY PREVIEW SOFTWARE, THE OPEN SOURCE SOFTWARE, THE DOCUMENTATION, AND ANY UPDATES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE. VMWARE AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. Licensee acknowledges that VMware has not publicly announced the availability of the Technology Preview Software, that such Technology Preview Software may contain features currently under development, that VMware has not promised or guaranteed to Licensee that such Technology Preview Software will be announced or made available to anyone in the future, that VMware has no express or implied obligation to Licensee to announce or introduce the Technology Preview Software, that VMware has no obligation to introduce a product similar to or compatible with the Technology Preview Software, and that any version number (if any) referenced is subject to change and does not in any way represent VMware's commitment to release any product in the future. Accordingly, Licensee acknowledges that any research or development that it performs regarding the Technology Preview Software or any product associated with the Technology Preview Software is done entirely at Licensee's own risk. Specifically, the Technology Preview Software may contain features, functionality or modules that will not be included in the production version of the Technology Preview Software, if released, or that will be marketed separately for additional fees.
23
+
24
+6.    OTHER PROVISIONS. (a) Governing Law. This Agreement, and all disputes arising out of or related thereto, shall be governed by and construed under the laws of the State of California without reference to conflict of laws principles. All such disputes shall be subject to the exclusive jurisdiction of the state and federal courts located in Santa Clara County, California, and the parties agree and submit to the personal and exclusive jurisdiction and venue of these courts. The United Nations Convention for the International Sale of Goods shall not apply. (b) Export Control. The Technology Preview Software is of United States origin and is provided subject to the U.S. Export Administration Regulations. Diversion contrary to U.S. law is prohibited. Without limiting the foregoing, you agree that (i) you are not, and are not acting on behalf of, any person who is a citizen, national, or resident of, or who is controlled by the government of, Cuba, Iran, North Korea, Sudan, or Syria, or any other country to which the United States has prohibited export transactions; (ii) you are not, and are not acting on behalf of, any person or entity listed on the U.S. Treasury Department list of Specially Designated Nationals and Blocked Persons, or the U.S. Commerce Department Denied Persons List or Entity List; and (iii) you will not use the Technology Preview Software for, and will not permit the Technology Preview Software to be used for, any purposes prohibited by law, including, without limitation, for any prohibited development, design, manufacture or production of missiles or nuclear, chemical or biological weapons. U.S. Export Control Classification Numbers (ECCN's) may be found at VMware help page: http://www.vmware.com/help/export-control. (c) Modification. This is the entire agreement between the parties relating to the subject matter hereof and all other terms are rejected. No waiver or modification of this Agreement shall be valid unless in writing signed by each party. The waiver of a breach of any term hereof shall in no way be construed as a waiver of any other term or breach hereof. If any provision of this Agreement is held by a court of competent jurisdiction to be contrary to law, the remaining provisions of this Agreement shall remain in full force and effect. (d) Data Privacy. Licensee agrees that VMware may process technical and related usage information about Licensee's use of the Technology Preview Software for statistical and analytical purposes. Usage information is collected strictly for internal statistical and analytical purposes for the development of VMware products and services. Licensee understands that any log files generated in order to obtain support from VMware may contain sensitive, confidential or personal information. Licensee should consider obfuscating any logs before sending them to VMware. VMware's privacy policy (http://www.vmware.com/help/privacy.html) shall apply.
25
+
26
+7.    ASSIGNMENT. Licensee shall not assign this Agreement or any rights or obligations hereunder, directly or indirectly, by operation of law, merger, acquisition of stock or assets, or otherwise, without the prior written consent of VMware. Any attempted assignment or transfer in violation of the foregoing will be null and void. Subject to the foregoing, this Agreement shall inure to the benefit of and be binding upon the parties and their respective successors and permitted assigns.
27
+
28
+8.    CONTACT INFORMATION. If you have any questions about this Agreement, please direct all correspondence to: VMware, Inc., 3401 Hillview Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com.
29
+
30
+Rev. 2015Apr16-3
0 31
\ No newline at end of file
... ...
@@ -29,7 +29,7 @@ class SelectDisk(object):
29 29
         self.menu_starty = self.win_starty + 6
30 30
         self.menu_height = 5
31 31
 
32
-        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Welcome to the Photon installer', True)
32
+        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Setup your disk', True)
33 33
         self.devices = Device.refresh_devices()
34 34
 
35 35
     def guided_partitions(self, device_index):
36 36
new file mode 100644
... ...
@@ -0,0 +1,178 @@
0
+#! /usr/bin/python2
1
+#
2
+#    Copyright (C) 2015 vmware inc.
3
+#
4
+#    Author: Mahmoud Bassiouny <mbassiouny@vmware.com>
5
+
6
+import curses
7
+from actionresult import ActionResult
8
+from action import Action
9
+
10
+class TextPane(Action):
11
+    def __init__(self, starty, maxx, width, text_file_path, height, menu_items):
12
+        self.head_position = 0  #This is the start of showing
13
+        self.menu_position = 0
14
+        self.lines = []
15
+        self.menu_items = menu_items;
16
+
17
+        self.width = width
18
+        
19
+        self.read_file(text_file_path, self.width - 3);
20
+
21
+        self.num_items = len(self.lines)
22
+        self.text_height = height - 2
23
+
24
+        # Check if we need to add a scroll bar
25
+        if self.num_items > self.text_height:
26
+            self.show_scroll = True
27
+        else:
28
+            self.show_scroll = False
29
+
30
+        # Some calculation to detitmine the size of the scroll filled portion
31
+        self.filled = int(round(self.text_height * self.text_height / float(self.num_items)))
32
+        if self.filled == 0:
33
+            self.filled += 1
34
+        for i in [1, 2]:
35
+            if (self.num_items - self.text_height) >= i and (self.text_height - self.filled) == (i - 1):
36
+                self.filled -= 1
37
+
38
+        self.window = curses.newwin(height, self.width)
39
+        self.window.bkgd(' ', curses.color_pair(2))
40
+
41
+        self.window.keypad(1)
42
+        self.panel = curses.panel.new_panel(self.window)
43
+
44
+        self.panel.move(starty, (maxx - self.width) / 2)
45
+        self.panel.hide()
46
+        curses.panel.update_panels()
47
+
48
+    def read_file(self, text_file_path, line_width):
49
+        with open(text_file_path, "r") as f:
50
+            for line in f:
51
+                # remove the trailing line feeds
52
+                while line.endswith('\r') or line.endswith('\n'):
53
+                    line = line[:-1]
54
+                # Adjust the words on the lines
55
+                while len(line) > line_width:
56
+                    sep_index = line_width
57
+                    while line[sep_index-1] != ' ' and line[sep_index] != ' ':
58
+                        sep_index = sep_index - 1
59
+                    currLine = line[:sep_index]
60
+                    if line[sep_index] == ' ':
61
+                        line = line[sep_index + 1:]
62
+                    else:
63
+                        line = line[sep_index:]
64
+
65
+                    # Lengthen the line with spaces
66
+                    self.lines.append(currLine + ' ' * (line_width - len(currLine)))
67
+
68
+                # lengthen the line with spaces
69
+                self.lines.append(line + ' ' * (line_width - len(line)))
70
+
71
+    def navigate(self, n):
72
+        self.head_position += n
73
+        if self.head_position < 0:
74
+            self.head_position = 0
75
+        elif self.head_position > (len(self.lines) - self.text_height + 1):
76
+            self.head_position = len(self.lines) - self.text_height + 1
77
+
78
+    def navigate_menu(self, n):
79
+        self.menu_position += n
80
+        if self.menu_position < 0:
81
+            self.menu_position = 0
82
+        elif self.menu_position >= len(self.menu_items):
83
+            self.menu_position = len(self.menu_items) - 1
84
+
85
+
86
+    def render_scroll_bar(self):
87
+        if self.show_scroll:
88
+            remaining_above = self.head_position
89
+            remaining_down = self.num_items - self.text_height - self.head_position#
90
+            
91
+            up = int(round(remaining_above * self.text_height / float(self.num_items)))
92
+            down = self.text_height - up - self.filled
93
+
94
+            if up == 0 and remaining_above > 0:
95
+                up += 1
96
+                down -= 1
97
+            if down == 0 and remaining_down > 0:
98
+                up -= 1
99
+                down += 1
100
+            if remaining_down == 0 and down != 0:
101
+                up += down
102
+                down = 0
103
+
104
+
105
+            for index in range(up):
106
+                self.window.addch(index, self.width - 2, curses.ACS_CKBOARD)
107
+
108
+            for index in range(self.filled):
109
+                self.window.addstr(index + up, self.width - 2, ' ', curses.A_REVERSE)
110
+
111
+            for index in range(down):
112
+                self.window.addch(index + up + self.filled, self.width - 2, curses.ACS_CKBOARD)
113
+
114
+    def refresh(self):
115
+        self.window.clear()
116
+        for index, line in enumerate(self.lines):
117
+            if (index < self.head_position):
118
+                continue
119
+            elif (index > self.head_position + self.text_height - 1):
120
+                continue
121
+
122
+            x = 0
123
+            y = index - self.head_position
124
+            if len(line) > 0:
125
+                self.window.addstr(y, x, line)
126
+
127
+        xpos = self.width
128
+        for index, item in enumerate(self.menu_items):
129
+            if index == self.menu_position:
130
+                mode = curses.color_pair(3)
131
+            else:
132
+                mode = curses.color_pair(2)
133
+
134
+            self.window.addstr(self.text_height + 1, xpos - len(item[0]) - 4, item[0], mode)
135
+            xpos = xpos - len(item[0]) - 4
136
+
137
+        self.render_scroll_bar()
138
+
139
+        self.window.refresh()
140
+        self.panel.top()
141
+        self.panel.show()
142
+        curses.panel.update_panels()
143
+        curses.doupdate()
144
+
145
+    def hide(self):
146
+        self.panel.hide()
147
+        curses.panel.update_panels()
148
+        curses.doupdate()
149
+
150
+    def do_action(self):
151
+        while True:
152
+            self.refresh()
153
+
154
+            key = self.window.getch()
155
+
156
+            if key in [curses.KEY_ENTER, ord('\n')]:
157
+                self.hide()
158
+                return self.menu_items[self.menu_position][1]()
159
+
160
+            if key == curses.KEY_UP:
161
+                self.navigate(-1)
162
+            elif key == curses.KEY_DOWN:
163
+                self.navigate(1)
164
+
165
+            elif key == curses.KEY_LEFT:
166
+                self.navigate_menu(1)
167
+            elif key == curses.KEY_RIGHT:
168
+                self.navigate_menu(-1)
169
+
170
+            elif key == curses.KEY_NPAGE:
171
+                self.navigate(self.text_height)
172
+            elif key == curses.KEY_PPAGE:
173
+                self.navigate(-self.text_height)
174
+
175
+            elif key == curses.KEY_HOME:
176
+                self.head_position = 0
177
+