equal
deleted
inserted
replaced
94 assert repo |
94 assert repo |
95 self.cnx = cnx |
95 self.cnx = cnx |
96 self.repo = repo |
96 self.repo = repo |
97 self.session = cnx.session |
97 self.session = cnx.session |
98 elif connect: |
98 elif connect: |
99 self.repo_connect() |
99 self.repo = config.repository() |
100 self.set_cnx() |
100 self.set_cnx() |
101 else: |
101 else: |
102 self.session = None |
102 self.session = None |
103 # no config on shell to a remote instance |
103 # no config on shell to a remote instance |
104 if config is not None and (cnx or connect): |
104 if config is not None and (cnx or connect): |
150 except (KeyboardInterrupt, EOFError): |
150 except (KeyboardInterrupt, EOFError): |
151 print 'aborting...' |
151 print 'aborting...' |
152 sys.exit(0) |
152 sys.exit(0) |
153 self.session = self.repo._get_session(self.cnx.sessionid) |
153 self.session = self.repo._get_session(self.cnx.sessionid) |
154 |
154 |
155 |
|
156 @cached |
|
157 def repo_connect(self): |
|
158 self.repo = repoapi.get_repository(config=self.config) |
|
159 return self.repo |
|
160 |
|
161 def cube_upgraded(self, cube, version): |
155 def cube_upgraded(self, cube, version): |
162 self.cmd_set_property('system.version.%s' % cube.lower(), |
156 self.cmd_set_property('system.version.%s' % cube.lower(), |
163 unicode(version)) |
157 unicode(version)) |
164 self.commit() |
158 self.commit() |
165 |
159 |
192 |
186 |
193 # server specific migration methods ######################################## |
187 # server specific migration methods ######################################## |
194 |
188 |
195 def backup_database(self, backupfile=None, askconfirm=True, format='native'): |
189 def backup_database(self, backupfile=None, askconfirm=True, format='native'): |
196 config = self.config |
190 config = self.config |
197 repo = self.repo_connect() |
191 repo = self.repo |
198 # paths |
192 # paths |
199 timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') |
193 timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') |
200 instbkdir = osp.join(config.appdatahome, 'backup') |
194 instbkdir = osp.join(config.appdatahome, 'backup') |
201 if not osp.exists(instbkdir): |
195 if not osp.exists(instbkdir): |
202 os.makedirs(instbkdir) |
196 os.makedirs(instbkdir) |
269 with open(osp.join(tmpdir, 'format.txt')) as format_file: |
263 with open(osp.join(tmpdir, 'format.txt')) as format_file: |
270 written_format = format_file.readline().strip() |
264 written_format = format_file.readline().strip() |
271 if written_format in ('portable', 'native'): |
265 if written_format in ('portable', 'native'): |
272 format = written_format |
266 format = written_format |
273 self.config.init_cnxset_pool = False |
267 self.config.init_cnxset_pool = False |
274 repo = self.repo_connect() |
268 repo = self.repo |
275 source = repo.system_source |
269 source = repo.system_source |
276 try: |
270 try: |
277 source.restore(osp.join(tmpdir, source.uri), self.confirm, drop, format) |
271 source.restore(osp.join(tmpdir, source.uri), self.confirm, drop, format) |
278 except Exception as exc: |
272 except Exception as exc: |
279 print '-> error trying to restore %s [%s]' % (source.uri, exc) |
273 print '-> error trying to restore %s [%s]' % (source.uri, exc) |