Skip to main content

Posts

Python - SFTP connection, upload file and delete a file from SFTP server

 Below is the python program which will connect to SFTP server, upload a file to SFTP server and delete a specific file from SFTP server. Here is the code: import paramiko from paramiko.ssh_exception import SSHException import os import time hostname = 'hostname here' username = 'username here' password = 'password here' port = PORT_NO SSH_Client = paramiko.SSHClient() SSH_Client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) SSH_Client.connect(hostname=hostname,                    port=port,                    username=username,                    password=password,                    look_for_keys=False) sftp_client = SSH_Client.open_sftp() print("Connection successfully established ... ") remoteFilePath = "/home" # Output: lists of files ['my-directory', 'my-file'] print(f"li...

Python - Change filename for all files present in a specific folder

 Following is the Python program which will Change filename for all files present in a specific folder. Following is the code. import glob import os path = 'path to folder' i=1 for i, filename in enumerate(glob.glob(path + '*.xlsx')):     os.rename(filename, os.path.join(path, 'QA_Scenario_1__' + str(i+1) + '.xlsx')) j=i for j, filename in enumerate(glob.glob(path + '*.xls')):     os.rename(filename, os.path.join(path, 'Testing_Scenario_1__' + str(j+1) + '.xls'))

Some GUI examples in Python using customtkinter

 Some GUI examples in Python using customtkinter import customtkinter import os from PIL import Image class ScrollableCheckBoxFrame(customtkinter.CTkScrollableFrame):     def __init__(self, master, item_list, command=None, **kwargs):         super().__init__(master, **kwargs)         self.command = command         self.checkbox_list = []         for i, item in enumerate(item_list):             self.add_item(item)     def add_item(self, item):         checkbox = customtkinter.CTkCheckBox(self, text=item)         if self.command is not None:             checkbox.configure(command=self.command)         checkbox.grid(row=len(self.checkbox_list), column=0, pady=(0, 10))         self.checkbox_list.append(checkbox)     def remove_item(self, it...

File Compare Tool in Python and tkinter

 Below is the desktop application developed in Python to compare 2 files and find out the differences. Here is the code: import tkinter as tk from tkinter import filedialog from tkinter import ttk import time import threading class TextComparerApp:     def __init__(self, root):         self.root = root         self.root.title("Text Compare: by Vinayak")         self.root.geometry("800x730")  # Set default window size to 800x730 pixels         # Frame to hold upload buttons         self.upload_frame = tk.Frame(root)         self.upload_frame.pack(pady=10)         # First file upload button         self.upload_button1 = tk.Button(self.upload_frame, activebackground="#99e0aa", text="<--- Insert File 1 --->",                             ...

Add worklog in Jira using Python

 Below is the Python code to add the worklog in Jira. You need to install a request library for this. Here is the code: import requests from requests.auth import HTTPBasicAuth import json url = "https://your jira address here/rest/api/2/issue/ticket_number/worklog" auth = HTTPBasicAuth("username", "jira access token") headers = {     "Accept": "application/json",     "Content-Type": "application/json" } payload = json.dumps({     "comment": {         "content": [             {                 "content": [                     {                         "text": "This is for QA Testing",                         "type": "text"                     } ...

create a groups in Jira API using Python

 Below is the Python code to get create a groups in Jira. You need to install a request library for this. Here is the code: import requests from requests.auth import HTTPBasicAuth import json url = "https://your jira address here/rest/api/3/group" headers = {   "Accept": "application/json",   "Content-Type": "application/json" } payload = json.dumps( {   "name": "QA" } ) response = requests.request(    "POST",    url,    data=payload,    headers=headers,    auth=auth ) print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

Python code to get the groups in Jira

 Below is the Python code to get the groups in Jira. You need to install a request library for this. Here is the code: import requests url = "https://your jira address here/rest/api/2/user/groups?Name=jira name " \       "&accountId=account-id&username=username " payload={} headers = {    'User-Agent': 'Apidog/1.0.0 (https://apidog.com)' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ============================================================= import requests from requests.auth import HTTPBasicAuth import json url = "https://your jira address here/rest/api/3/group" auth = HTTPBasicAuth("username", "jira access token") headers = {     "Accept": "application/json" } query = {     'groupId': 'groupId' } response = requests.request(     "GET",     url,     headers=headers,     params=query,     auth=auth ) print(js...