Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions ghe2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,15 @@
ghe2json command line tool to convert gheboot output to json.
"""

import os
import sys
import string
import time
import random
import argparse
import logging
import logging.config
from pathlib import Path
import subprocess
from datetime import datetime
import re
import thepower
import json
import pprint


def clear_screen():
# Check if the operating system is Windows
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')


def print_progress_bar():
total_steps = 10 # Number of steps in the progress bar
progress_symbol = "="
empty_symbol = " "
progress_bar_length = 50 # Length of the progress bar

print("Converting Hubot output...")
for step in range(total_steps + 1):
# Calculate the percentage of completion
percent_complete = step / total_steps
progress_length = int(percent_complete * progress_bar_length)

# Construct the progress bar string
progress_bar = progress_symbol * progress_length
empty_space = empty_symbol * (progress_bar_length - progress_length)
progress_display = f"[{progress_bar}{empty_space}] {percent_complete * 100:.2f}%"

# Print the progress bar
sys.stdout.write(f"\r{progress_display}")
sys.stdout.flush()

# Sleep for a random amount of time less than 0.4 seconds to simulate work
time.sleep(random.uniform(0, 0.4))

# Call the function to display the progress bar


def generate_template(environment):
e = json.loads(environment)
values = {}
Expand Down Expand Up @@ -142,7 +99,7 @@ def main(args):
message="""Please paste below the output from gheboot informing you that the
appliance is ready (optionally paste in a token for an admin user
with all scopes set). When that's done press the return key twice to proceed:\n"""
clear_screen()
thepower.clear_screen()
print(f"\033[93m\n\n{message}\033[0m\n")
lines = []
while True:
Expand All @@ -168,7 +125,7 @@ def main(args):

print(f"\033[92m")
print("\n")
print_progress_bar()
thepower.print_progress_bar()
print(f"""\n\nConverted Hubot output to "{args.environment_file}" file:\n""")
with open(args.environment_file, "r") as f:
j = json.loads(f.read())
Expand Down
43 changes: 3 additions & 40 deletions terraformworkspaceid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,9 @@
import argparse
import json
import logging
import os
import pprint
import random
import shlex
import sys
import time

def clear_screen():
# Check if the operating system is Windows
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')


def print_progress_bar():
total_steps = 10 # Number of steps in the progress bar
progress_symbol = "="
empty_symbol = " "
progress_bar_length = 50 # Length of the progress bar

print("Converting Hubot output...")
for step in range(total_steps + 1):
# Calculate the percentage of completion
percent_complete = step / total_steps
progress_length = int(percent_complete * progress_bar_length)

# Construct the progress bar string
progress_bar = progress_symbol * progress_length
empty_space = empty_symbol * (progress_bar_length - progress_length)
progress_display = f"[{progress_bar}{empty_space}] {percent_complete * 100:.2f}%"

# Print the progress bar
sys.stdout.write(f"\r{progress_display}")
sys.stdout.flush()

# Sleep for a random amount of time less than 0.4 seconds to simulate work
time.sleep(random.uniform(0, 0.4))

# Call the function to display the progress bar
import thepower


def terraform_workspace_id(text):
Expand Down Expand Up @@ -76,7 +39,7 @@ def main(args):
if args.ghe_file == False:
message="""Please paste below the output from gheboot informing you
Terraform Workspace ID (ws-xxxxxx). When that's done press the return key twice to proceed:\n"""
clear_screen()
thepower.clear_screen()
print(f"\033[93m\n\n{message}\033[0m\n")
lines = []
while True:
Expand All @@ -102,7 +65,7 @@ def main(args):

print(f"\033[92m")
print("\n")
print_progress_bar()
thepower.print_progress_bar()
print(f"""\n\nConverted Hubot output to "{args.environment_file}" file:\n""")
with open(args.environment_file, "r") as f:
j = json.loads(f.read())
Expand Down
37 changes: 37 additions & 0 deletions thepower.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
__version__ = "0.1.0"
__license__ = "MIT"

import random
import sys
import string
import os.path
import logging
import time
import urllib
import json
import subprocess
Expand Down Expand Up @@ -263,6 +265,41 @@ def read_dotcom_config(dotcom_config_file):
return dotcom_config


def clear_screen():
# Check if the operating system is Windows
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')


def print_progress_bar():
total_steps = 10 # Number of steps in the progress bar
progress_symbol = "="
empty_symbol = " "
progress_bar_length = 50 # Length of the progress bar

print("Converting Hubot output...")
for step in range(total_steps + 1):
# Calculate the percentage of completion
percent_complete = step / total_steps
progress_length = int(percent_complete * progress_bar_length)

# Construct the progress bar string
progress_bar = progress_symbol * progress_length
empty_space = empty_symbol * (progress_bar_length - progress_length)
progress_display = f"[{progress_bar}{empty_space}] {percent_complete * 100:.2f}%"

# Print the progress bar
sys.stdout.write(f"\r{progress_display}")
sys.stdout.flush()

# Sleep for a random amount of time less than 0.4 seconds to simulate work
time.sleep(random.uniform(0, 0.4))

# Call the function to display the progress bar


if __name__ == "__main__":
""" This is executed when run from the command line """
main()