Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. import os
  2. from pathlib import Path
  3. import fileinput
  4. import git
  5.  
  6. def relate_to_git():
  7. print("Currently working on: " + os.getcwd())
  8. repo = git.Repo(repos)
  9. print(repo.git.branch('-a'))
  10. print(repo.git.checkout("master"))
  11. print(repo.git.pull())
  12.  
  13. filename = Path(os.getcwd() + '/provision/k8s/new-production/deployment.yaml')
  14.  
  15. if filename.is_file():
  16. filename = Path(os.getcwd() + '/provision/k8s/new-production/deployment.yaml')
  17. else:
  18. filename = Path(os.getcwd() + '/provision/k8s/production/deployment.yaml')
  19.  
  20. old = "targetAverageValue"
  21. new = " targetAverageUtilization: 90"
  22.  
  23. for line in fileinput.input(filename, inplace=1):
  24. line = line.rstrip()
  25. if old in line:
  26. line = new
  27. print(line)
  28. try:
  29. repo.git.add(update=True)
  30. repo.git.commit('-m', 'Adjust request and limit on source')
  31. # repo.git.push('origin', 'master')
  32. except:
  33. print("Should be ignored")
  34. repo.git.push('origin', 'master')
  35.  
  36. full = ('frontend', 'backend')
  37.  
  38. for seperate in full:
  39. os.chdir("/Users/luanvn/logistic-" + seperate)
  40. if seperate == "backend":
  41. currentDirectory = os.getcwd()
  42. for sub_dir in os.listdir(currentDirectory):
  43. if sub_dir != "consumer":
  44. repos = os.chdir("/Users/luanvn/logistic-backend/" + sub_dir)
  45. relate_to_git()
  46. else:
  47. os.chdir("/Users/luanvn/logistic-backend/consumer")
  48. currentDirectory = os.getcwd()
  49. for sub_dir in os.listdir(currentDirectory):
  50. repos = os.chdir("/Users/luanvn/logistic-backend/consumer/" + sub_dir)
  51. relate_to_git()
  52. else:
  53. currentDirectory = os.getcwd()
  54. for sub_dir in os.listdir(currentDirectory):
  55. repos = os.chdir("/Users/luanvn/logistic-frontend/" + sub_dir)
  56. relate_to_git()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement