<s> import os , sys , string , math <EOL> sys . path . append ( os . path . abspath ( os . getenv ( '<STR_LIT>' ) + "<STR_LIT>" ) ) <EOL> from git_report_structure import * <EOL> from gm_resources import * <EOL> from utility import * <EOL> def is_valid_repo_dir ( repo_name ) : <EOL> rep_dir = get_repository_path ( repo_name ) <EOL> return is_valid_dir ( rep_dir ) <EOL> def is_valid_remote ( rname ) : <EOL> remotes , rsyms = get_remote_names ( ) <EOL> if rname in remotes : <EOL> return True <EOL> else : <EOL> return False <EOL> def get_repository_path ( repo_name ) : <EOL> search_paths = get_repositories_search_dirs ( ) <EOL> folder_path = repo_name <EOL> for rp in search_paths : <EOL> ppath = rp + repo_name <EOL> if is_valid_dir ( ppath ) is True : <EOL> folder_path = ppath <EOL> break <EOL> return folder_path <EOL> def git_push_remotes ( repo_name , remote_list , branch_name ) : <EOL> rep_path = get_repository_path ( repo_name ) <EOL> os . chdir ( rep_path ) <EOL> rc , git_st = commands . getstatusoutput ( '<STR_LIT>' ) <EOL> if rc != <NUM_LIT:0> : <EOL> print '<STR_LIT>' + rep_path + '<STR_LIT:]>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> smsg = '<STR_LIT>' <EOL> for remote in remote_list : <EOL> if is_valid_remote ( remote ) is False : <EOL> smsg += '<STR_LIT>' + remote + '<STR_LIT>' <EOL> continue <EOL> cmd = '<STR_LIT>' + remote + '<STR_LIT:U+0020>' + branch_name <EOL> print repo_name + '<STR_LIT>' + cmd <EOL> rc , git_st = commands . getstatusoutput ( cmd ) <EOL> if rc != <NUM_LIT:0> : <EOL> print '<STR_LIT>' + remote + '<STR_LIT:]>' <EOL> smsg += '<STR_LIT>' . ljust ( <NUM_LIT> ) + '<STR_LIT>' + repo + '<STR_LIT:\n>' <EOL> print git_st <EOL> print '<STR_LIT>' <EOL> print smsg <EOL> def git_push_projects ( repo_names , branch_name , remote_name ) : <EOL> smsg = '<STR_LIT>' <EOL> for repo in repo_names : <EOL> repo_path = get_repository_path ( repo ) <EOL> if is_valid_repo_dir ( repo_path ) is False : <EOL> smsg += '<STR_LIT>' . ljust ( <NUM_LIT> ) + '<STR_LIT>' + repo + '<STR_LIT:\n>' <EOL> continue <EOL> os . chdir ( repo_path ) <EOL> cmd = '<STR_LIT>' + remote_name + '<STR_LIT:U+0020>' + branch_name <EOL> print repo . ljust ( <NUM_LIT> ) + '<STR_LIT>' + cmd <EOL> g = generate_git_report ( repo ) <EOL> if g . isrepo == - <NUM_LIT:1> : <EOL> smsg += '<STR_LIT>' . ljust ( <NUM_LIT> ) + '<STR_LIT>' + repo + '<STR_LIT:\n>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if g . commit == <NUM_LIT:1> : <EOL> smsg += '<STR_LIT>' . ljust ( <NUM_LIT> ) + '<STR_LIT>' + repo + '<STR_LIT:\n>' <EOL> continue <EOL> rc , git_staus = commands . getstatusoutput ( cmd ) <EOL> if rc != <NUM_LIT:0> : <EOL> smsg += '<STR_LIT>' . ljust ( <NUM_LIT> ) + '<STR_LIT>' + repo + '<STR_LIT:\n>' <EOL> print git_staus <EOL> continue <EOL> print '<STR_LIT>' <EOL> print smsg <EOL> def generate_git_report ( repo_name ) : <EOL> if is_valid_repo_dir ( repo_name ) is False : <EOL> return None <EOL> g = GitReport ( ) <EOL> g . repo_name = repo_name <EOL> g . path = get_repository_path ( repo_name ) <EOL> g . parse_status ( ) <EOL> g . parse_remote ( ) <EOL> g . parse_last_commit_history ( ) <EOL> return g <EOL> def generate_remote_path ( remote_name , repo_name ) : <EOL> return get_mount_point ( remote_name ) + '<STR_LIT>' + repo_name + '<STR_LIT>' </s>
