How I Automate My Freelance Workflow with Python
As a freelance developer, I've learned that automation is key to increasing productivity and reducing the time spent on repetitive tasks. In this article, I'll share how I use Python to automate my freelance workflow, from project management to invoicing.
Project Management Automation
I use the github API to automate my project management workflow. Here's an example of how I use Python to create a new GitHub issue:
import requests
# GitHub API credentials
username = "your-username"
password = "your-password"
repo_name = "your-repo-name"
# Create a new GitHub issue
def create_issue(title, body):
url = f"https://api.github.com/repos/{username}/{repo_name}/issues"
headers = {"Content-Type": "application/json"}
data = {"title": title, "body": body}
response = requests.post(url, headers=headers, json=data, auth=(username, password))
return response.json()
# Example usage:
issue_title = "New Project Task"
issue_body = "This is a new task for the project"
create_issue(issue_title, issue_body)
This script creates a new GitHub issue with the specified title and body. I use this script to automate the process of creating new tasks for my projects.
Time Tracking Automation
I use the toggl API to automate my time tracking workflow. Here's an example of how I use Python to start a new Toggl timer:
import requests
# Toggl API credentials
api_token = "your-api-token"
workspace_id = "your-workspace-id"
# Start a new Toggl timer
def start_timer(project_name, task_name):
url = f"https://api.toggl.com/reports/v8/details"
headers = {"Content-Type": "application/json"}
data = {
"user_agent": "your-app-name",
"workspace_id": workspace_id,
"project_name": project_name,
"task_name": task_name
}
response = requests.post(url, headers=headers, json=data, auth=(api_token, "api_token"))
return response.json()
# Example usage:
project_name = "My Project"
task_name = "Task 1"
start_timer(project_name, task_name)
This script starts a new Toggl timer with the specified project and task names. I use this script to automate the process of starting new timers for my projects.
Invoicing Automation
I use the pdfkit library to automate my invoicing workflow. Here's an example of how I use Python to generate a new invoice:
python
import pdfkit
from datetime import datetime
# Invoice data
invoice_number = "INV001"
invoice_date = datetime.now().strftime("%Y-%m-%d")
client_name = "John Doe"
client_address = "123 Main St, Anytown, USA"
project_name = "My Project"
project_hours = 10
project_rate = 100
# Generate the invoice
def generate_invoice(invoice_number, invoice_date, client_name, client_address, project_name, project_hours, project_rate):
html = f"""
<html>
<body>
<h1>Invoice {invoice_number}</h1>
<p>Date: {invoice_date}</p>
<p>Client: {client_name}</p>
<p>Address: {client_address}</p>
<p>Project: {project_name}</p>
<p>Hours: {project_hours}</p>
<p>Rate: ${project_rate}/hr</p>
<p>Total: ${project_hours * project_rate}</p>
</body>
</html>
"""
options = {
"page-size": "Letter",
"margin-top": "0
Top comments (0)