def _parse_revisions(self, number_of_commits=1): try: files = self.git_wrapper.get_changed_files(number_of_commits) return list(set(files)) if files else [] except Exception as e: Logging.log("git error finding changed files using git wrapper") raise e
def execute(self): self.git_wrapper.pull() self.git_wrapper.add() new_hash = self.git_wrapper.commit(self.commit_message) files = self.git_wrapper.get_file_names_from_hash(new_hash) results2 = self.git_wrapper.push() Logging.log('Git pushed {0} files:\r\n\t\t{1}'.format( len(files), '\r\n\t\t'.join(files)))
def upload(self, file_name, folder_path, overwrite, content_bytes): warnings = None try: warnings = self.client.service.CreateReport(file_name, folder_path, overwrite, content_bytes, None) if warnings: Logging.log_to_file(SSRSReportUploadedRecord(folder_path, file_name, warnings)) except Exception as e: print(SSRSReportUploadedRecord(folder_path, file_name, warnings, e))
def _is_valid_file(self, file_path): if not FilePathHelper.is_valid_file_path(file_path): Logging.log("Skipping (can't find)'{0}'".format(file_path)) return False if not FilePathHelper.is_valid_file_ext( file_path, self._accepted_file_extensions): Logging.log("Skipping (file type) '{0}'".format(file_path)) return False return True
def pull(self): try: results = self.origin.pull() except Exception as e: Logging.log( '\r\n\tGITTY UP PULL FAILED: Resolve any conflicts between your pending commit and the remote repository and try again.\r\n' ) raise e return results
def upload_single(self, file_path): if not self._is_valid_file(file_path): return ssrs_server_rel_path = self._get_ssrs_rel_path(file_path) file_name = FilePathHelper.get_file_name_without_extension(file_path) Logging.log("Uploading '{0}' to '{1}' folder".format( file_name, ssrs_server_rel_path)) content_bytes = self._get_file_contents(file_path) self._ssrs_soap_wrapper.upload(file_name, ssrs_server_rel_path, True, content_bytes)
def execute(self): server_details = self._read_config().get('ssrs_servers', []) uploaders = [self._configure_uploader(d) for d in server_details] if not uploaders: Logging.log('There appears to be no ssrs servers listed in the config.json file') return files = self._parse_revisions(self.number_of_commits) if not files: Logging.log("There appears to be no files changed in the last {0} commits...".format(self.number_of_commits)) return files = [self._normalize_file_name(f) for f in files] for uploader in uploaders: self._deploy_to_ssrs(files, uploader)
def _configure_uploader(self, server_details): url = str(server_details['ssrs_service']).strip() try: name = str(server_details['name']).strip() user = str("{0}\{1}".format(str(server_details['domain']).strip(), server_details['username'])).strip() pw = str(server_details['password']).strip() if not user or not pw: user, pw = get_username_and_password("SSRS credentials required ({0})".format(name)) domain = str(server_details['domain']).strip() user = '******'.format(domain, user) ssrs_wrapper = SSRSReportService2005Wrapper(url, name, user, pw) ssrs_root_dir = "{0}{1}".format(self.git_wrapper.repo_path, server_details.get('root_dir', '')) ssrs_root_dir = FilePathHelper.convert_file_path_to_environment_standard(ssrs_root_dir.replace('//', '/')) return SSRSReportUploader(ssrs_root_dir, ssrs_wrapper) except Exception as e: Logging.log('Error configuring uploader for ssrs server ({0})'.format(url)) raise e
def _deploy_to_ssrs(self, file_paths, uploader): try: Logging.log("\r\n") Logging.log("SSRS SOAP Service: {0}".format(uploader.url)) isinstance(uploader, SSRSReportUploader) for f in file_paths: uploader.upload_single(f) Logging.log('Finished...') except: print("error deploying to ssrs ({0})".format(uploader.url))