12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- from dulwich import porcelain
- import os
- def is_file_locked(file_path):
- try:
- with open(file_path, 'r'):
- return False
- except IOError:
- return True
- def close_file(file_object):
- file_object.close()
- def release_file_resource(file_path):
- file_descriptor = os.open(file_path, os.O_RDONLY)
- os.close(file_descriptor)
- def unlock_file(file_path):
- if is_file_locked(file_path):
- with open(file_path, 'r') as file:
- close_file(file)
- release_file_resource(file_path)
- def ro():
- os.system("/etc/init.d/S01mount_ro start")
- def rw():
- os.system("/etc/init.d/S01mount_ro stop")
- localrep = "/home/"
- unlockfile = localrep + "cclb_launch"
- rw()
- unlock_file(unlockfile)
- porcelain.pull('.')
- ro()
|