Updating some help info on the client.
This commit is contained in:
parent
add3699c9e
commit
fd1dcdccd3
@ -28,7 +28,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--stream",
|
"--stream",
|
||||||
"-s",
|
"-s",
|
||||||
help="Use this option if you are piping output to another app. The output will not be streamed",
|
help="Use this option if you want to see the results in realtime. NOTE: You will not be able to pipe the output into another command.",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -121,23 +121,25 @@ class Update:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.root_api_url = "https://api.github.com/repos/danielmiessler/fabric/contents/patterns?ref=main"
|
self.root_api_url = "https://api.github.com/repos/danielmiessler/fabric/contents/patterns?ref=main"
|
||||||
self.config_directory = os.path.expanduser("~/.config/fabric")
|
self.config_directory = os.path.expanduser("~/.config/fabric")
|
||||||
self.pattern_directory = os.path.join(
|
self.pattern_directory = os.path.join(self.config_directory, "patterns")
|
||||||
self.config_directory, "patterns")
|
|
||||||
os.makedirs(self.pattern_directory, exist_ok=True)
|
os.makedirs(self.pattern_directory, exist_ok=True)
|
||||||
self.update_patterns() # Call the update process from a method.
|
self.update_patterns() # Call the update process from a method.
|
||||||
|
|
||||||
def update_patterns(self):
|
def update_patterns(self):
|
||||||
try:
|
try:
|
||||||
self.progress_bar = tqdm(desc="Downloading files", unit="file")
|
self.progress_bar = tqdm(desc="Downloading Patterns…", unit="file")
|
||||||
self.get_github_directory_contents(
|
self.get_github_directory_contents(
|
||||||
self.root_api_url, self.pattern_directory)
|
self.root_api_url, self.pattern_directory
|
||||||
|
)
|
||||||
# Close progress bar on success before printing the message.
|
# Close progress bar on success before printing the message.
|
||||||
self.progress_bar.close()
|
self.progress_bar.close()
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
# Ensure progress bar is closed on HTTPError as well.
|
# Ensure progress bar is closed on HTTPError as well.
|
||||||
self.progress_bar.close()
|
self.progress_bar.close()
|
||||||
if e.response.status_code == 403:
|
if e.response.status_code == 403:
|
||||||
print("GitHub API rate limit exceeded. Please wait before trying again.")
|
print(
|
||||||
|
"GitHub API rate limit exceeded. Please wait before trying again."
|
||||||
|
)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
print(f"Failed to download patterns due to an HTTP error: {e}")
|
print(f"Failed to download patterns due to an HTTP error: {e}")
|
||||||
@ -156,8 +158,9 @@ class Update:
|
|||||||
|
|
||||||
def process_item(self, item, local_dir):
|
def process_item(self, item, local_dir):
|
||||||
if item["type"] == "file":
|
if item["type"] == "file":
|
||||||
self.download_file(item["download_url"],
|
self.download_file(
|
||||||
os.path.join(local_dir, item["name"]))
|
item["download_url"], os.path.join(local_dir, item["name"])
|
||||||
|
)
|
||||||
elif item["type"] == "dir":
|
elif item["type"] == "dir":
|
||||||
new_dir = os.path.join(local_dir, item["name"])
|
new_dir = os.path.join(local_dir, item["name"])
|
||||||
os.makedirs(new_dir, exist_ok=True)
|
os.makedirs(new_dir, exist_ok=True)
|
||||||
@ -172,18 +175,18 @@ class Update:
|
|||||||
self.process_item(item, local_dir)
|
self.process_item(item, local_dir)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
if e.response.status_code == 403:
|
if e.response.status_code == 403:
|
||||||
print("GitHub API rate limit exceeded. Please wait before trying again.")
|
print(
|
||||||
|
"GitHub API rate limit exceeded. Please wait before trying again."
|
||||||
|
)
|
||||||
self.progress_bar.close() # Ensure the progress bar is cleaned up properly
|
self.progress_bar.close() # Ensure the progress bar is cleaned up properly
|
||||||
else:
|
else:
|
||||||
print(
|
print(f"Failed to fetch directory contents due to an HTTP error: {e}")
|
||||||
f"Failed to fetch directory contents due to an HTTP error: {e}")
|
|
||||||
|
|
||||||
|
|
||||||
class Setup:
|
class Setup:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_directory = os.path.expanduser("~/.config/fabric")
|
self.config_directory = os.path.expanduser("~/.config/fabric")
|
||||||
self.pattern_directory = os.path.join(
|
self.pattern_directory = os.path.join(self.config_directory, "patterns")
|
||||||
self.config_directory, "patterns")
|
|
||||||
os.makedirs(self.pattern_directory, exist_ok=True)
|
os.makedirs(self.pattern_directory, exist_ok=True)
|
||||||
self.env_file = os.path.join(self.config_directory, ".env")
|
self.env_file = os.path.join(self.config_directory, ".env")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user