Advertisement
D3ENNY

backup

May 12th, 2024
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.94 KB | None | 0 0
  1. Traceback (most recent call last):
  2.   File "/home/denny/Project/Python/.dotfiles/backup.py", line 75, in <module>
  3.     origin.push()
  4.   File "/home/denny/Project/Python/.dotfiles/venv/lib/python3.12/site-packages/git/remote.py", line 1203, in push
  5.     return self._get_push_info(proc, progress, kill_after_timeout=kill_after_timeout)
  6.            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  7.   File "/home/denny/Project/Python/.dotfiles/venv/lib/python3.12/site-packages/git/remote.py", line 968, in _get_push_info
  8.     proc.wait(stderr=stderr_text)
  9.   File "/home/denny/Project/Python/.dotfiles/venv/lib/python3.12/site-packages/git/cmd.py", line 834, in wait
  10.     raise GitCommandError(remove_password_if_present(self.args), status, errstr)
  11. git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  12.   cmdline: git push --porcelain -- origin
  13.   stderr: 'error: RPC failed; HTTP 500 curl 92 HTTP/2 stream 7 was not closed cleanly: CANCEL (err 8)
  14. fatal: the remote end hung up unexpectedly'
  15.  
  16. ====================
  17.  
  18.  
  19. repo = Repo('./')
  20. origin = repo.remote('origin')
  21.  
  22. ##########################
  23. #        FUNCTIONS       #
  24. ##########################
  25.  
  26. def enhanced_copy(src, dst, key):
  27.     try:
  28.         if isdir(src):
  29.             copytree(src, dst, symlinks=True, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False, dirs_exist_ok=False)
  30.         else:
  31.             makedirs(dirname(dst), exist_ok=True)
  32.             copy2(src, dst)
  33.     except (FileNotFoundError, FileExistsError) as err:
  34.         with open(f"{key}/log.txt", 'a+') as log:
  35.             log.write(f'src: {src} - dst: {dst}\n{err}\n\n')
  36.    
  37. def apply_config(key):
  38.     config = configFile.configs.get(key)
  39.     if config:
  40.         config['msg']
  41.         paths = config['path']
  42.        
  43.         rmtree(key, ignore_errors=True)
  44.         makedirs(key, exist_ok=True)
  45.        
  46.         for path in paths:
  47.             print(f"start saving {path} folder")
  48.            
  49.             with tqdm(total=len(paths[path])) as progressBar:
  50.                 for file in paths[path]:
  51.                     enhanced_copy(f"{path}/{file}", f"{key}/{path[1:]}/{file}", key)
  52.                     sleep(0.01)
  53.                     progressBar.update(1)
  54.             commit(key, f"update {path} folder in {key} dotfile")
  55.  
  56. def commit(src, msg):
  57.     for i in glob(join(src, '.*')) + glob(join(src, '*')):
  58.         repo.index.add(i)
  59.         print(f'{i} folder added to local repository')
  60.         repo.index.commit(msg)
  61.     print("commits mades")
  62.    
  63.    
  64. ##########################
  65. #         STARTUP        #
  66. ##########################
  67. #TODO: DA AUTOMATIZZARE
  68. choise = int(input('do you want to update KDE config or hyprland config?\n[1] KDE plasma\n[2] HyprlandWM\n'))
  69. system('clear')
  70. if choise == 1:
  71.     apply_config("kde")
  72. elif choise == 2:
  73.     apply_config("hyprland")
  74. else:
  75.     print('unhandled input')
  76.     exit(1)
  77.  
  78. origin.push()
  79. print("local repository pushed on github")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement