Last active
February 12, 2024 15:03
-
-
Save fastfingertips/e5bd853c8592e000589738b039b0e170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from github import Github | |
from github import Auth | |
import github.InputFileContent | |
import json | |
def update_gist_file(gist_id, file_name, content): | |
if isinstance(content, dict): | |
content = json.dumps(content) | |
content = github.InputFileContent(content) | |
gist = g.get_gist(gist_id) | |
gist.edit(files = {file_name: content}) | |
github_token = "" | |
gist_id = '' | |
gist_file_name = '' | |
auth = Auth.Token(github_token) | |
g = Github(auth=auth) | |
content = {'is_active': False} | |
update_gist_file(gist_id, gist_file_name, content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from github import Github, Auth, InputFileContent | |
import json | |
# Function to update the content of a Gist file | |
def update_gist_file(gist_id, file_name, content): | |
if isinstance(content, dict): | |
content = json.dumps(content) # Convert content to JSON string if it's a dictionary | |
content = InputFileContent(content) # Create InputFileContent object with the content | |
gist = g.get_gist(gist_id) # Get the Gist object using its ID | |
gist.edit(files={file_name: content}) # Edit the Gist file with the new content | |
# Function to activate the Gist file | |
def activate(): | |
content = {'is_active': True} # Define content to activate the file | |
update_gist_file(gist_id, file_name, content) # Update the Gist file with the new content | |
# Function to deactivate the Gist file | |
def deactivate(): | |
content = {'is_active': False} # Define content to deactivate the file | |
update_gist_file(gist_id, file_name, content) # Update the Gist file with the new content | |
# GitHub API authentication | |
auth = Auth.Token("") # Provide your GitHub personal access token here | |
g = Github(auth=auth) # Initialize GitHub object with authentication | |
# Gist file name and ID | |
file_name = '' # Name of the Gist file to be updated | |
gist_id = '' # ID of the Gist | |
# Creating the Tkinter application | |
root = tk.Tk() # Create the main application window | |
root.title("GitHub Gist Status Updater") # Set the title of the window | |
# Buttons to activate and deactivate the Gist file | |
activate_button = tk.Button(root, text="Activate", command=activate) # Button to activate the Gist file | |
activate_button.pack() # Add the button to the window | |
deactivate_button = tk.Button(root, text="Deactivate", command=deactivate) # Button to deactivate the Gist file | |
deactivate_button.pack() # Add the button to the window | |
root.mainloop() # Start the Tkinter event loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment