Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Easily Manage Browser Cookies Across Chrome and Firefox with Python!

Hey, r/Python community!

I've developed a versatile Python script that extracts and converts cookies from **Google Chrome and Mozilla Firefox** into commonly used formats. This tool is useful for developers and sysadmins who need to manage cookies for automation tasks, testing, or migrations between different environments.

## **What My Project Does**

### **Functionalities of the Script**

1. **Extract Cookies** from the SQLite databases of Chrome and Firefox.
2. **Convert Cookies** to either Netscape or JavaScript formats.
3. **Combine Cookies** from both browsers into a single file when working with the Netscape format. This feature is particularly useful for tools like `curl`, `wget`, or `aria2` that may require a unified cookie file.

## **Target Audience**

This script is specifically designed for:
- **Developers** testing web applications with real user cookies.
- **Sysadmins** who manage user sessions across different systems.
- **Tech Enthusiasts** looking to automate or manipulate browser data.

## **Comparison**

### **Key Features:**

- **Support for Multiple Browsers**: Extract cookies from Chrome and Firefox.
- **Flexible Output Formats**: Convert cookies to Netscape or JavaScript formats, depending on your needs.
- **Combination Capability**: Allows cookies from multiple browsers to be combined into one file, simplifying the management of multiple browser environments.

## **Usage:**

Here’s how you can use this script effectively:

```bash
python3 cookie-converter.py -b <browser> -i <input_path> -o <output_path> -f

/r/Python
https://redd.it/1c63d5g
How to detrend oscillating data?



I'm currently doing my thesis and it requires data from accelerometers to be inputted onto the Artemis modal software for analysis. I have successfully obtained the acceleration data, but unfortunately some of the data collected shows a trend (either increasing or decreasing) when the data should be oscillating at around 0 (which is the case of any structure's vibrations). Is there a software that is capable of detrending these signals? Thanks

/r/Python
https://redd.it/1c6341a
Gunicorn and Nginx

i need to deploy a flask app and after a large search i reach that i need to deploy the app through nginx and gunicorn but the problem is i am not a programmer i am start learning programming and i found it so hard and every time i search for solution i found a huge amount of solution which is looks like different for me so the question is how i deploy the app using nginx and gunicorn ?

/r/django
https://redd.it/1c640rw
Through Model Migrations

So I made a through model for an m2m field, made a migration then it freaked out on migrate.

My understanding is that it tries to delete some pre-existing relationship table to accommodate the new custom one, for some reason.. It seems like the “easy fix” youtubers default to is deleting the database but that seems like a load of bs to me especially with valuable relationship data already there.

How am I supposed to remedy this change in production? Am i supposed to rollback migrations and do something fancy in the migration file to accommodate this? What is the process I should adhere to so I can accommodate these changes upon update in production? What is the order of operations here? Bc from time to time, yeah id like to change relationships like foreign key to m2m or add my own through model here and there..

/r/django
https://redd.it/1c66398
Question: Tool for editing figures in Python

So I'm trying to switch from MATLAB to Python for my numerical simulations.

One of the things I like about MATLAB is the ability to edit figures by adding stuff (eg arrows, lines, text ... ) to the figure within the software itself. This is what I mean. It's a very handy tool in my line of work and I use it often.

I was wondering if there's any similar tool for Python. I use matplotlib and seaborn. Any suggestions would be great. Thanks guys!

/r/Python
https://redd.it/1c5ixdz
ScrumMD: A CLI Scrum tool written in Python

I got grumpy with our Scrum process, and I thought about what kinda tool I'd love to work with... so I started making it in my beloved Python. I think it's mature enough I'd like to start giving it to other people.

It's called ScrumMD. It's open source, and you can already install it with pip (pip install scrummd) if you've got Python 3.10+. Documented, with tutorials on https://scrummd.readthedocs.io/en/stable/ and source on https://github.com/lkingsford/scrummd

What my project does

Short version is that it's some tools to support you storing all of your Scrum cards (or, I guess, other cards - tickets perhaps?) in markdown format on a local machine. There's intentionally a lot of flexibility - so, every card needs a summary, but everything else is fair game. You can configure to require fields for some collections (like needing status in stories), or limit fields (like requiring status be 'Done' or 'In Progress').

Target Audience

Limited, but public. It's chief audience is software engineers who work in self-organising teams. It's for teams who use processes like Scrum, but don't need the bureaucracy layers.

Honestly - I know it's niche. Heck, I won't even be using it at work myself. But, if I could, I would - because

/r/Python
https://redd.it/1c69jns
Django PyCryptodome AES decryption - ValueError: Padding is incorrect

I am trying to encrypt incoming files and than decrypt them later. I was following the [documentation](https://www.pycryptodome.org/src/cipher/classic#cbc-mode) for how to use AES with CBC mode for decryption and encryption.

My view for uploading and encrypting file:

@router.post("/upload_files")
def upload_files(request, file: UploadedFile = File(...)):
save_file = operations.aes_encryption(user_id=request.auth.id,file=request.FILES.get('file'))

def aes_encryption(self,user_id,file):
user = UserQueries.get_user(id=user_id)
key: bytes = bytes(user.key, "utf-8")
path: str = user.path

save_file = self._encrypt_file(file,key,path,user)

return save_file

def _encrypt_file(self,file,key,path,user):
file_content = file.read()

cipher = AES.new(key, AES.MODE_CBC)


/r/django
https://redd.it/1c6cewm
Using multiple apps in a project

Hey everyone, django/backend dev beginner here, have what might be a newbie question and i suppose it might lead to more of a design discussion than a one size fits all answer...

&#x200B;

Essentially wondering when I should be using multiple apps in a project?

&#x200B;

For context, im working on a patient portal type of application in a health care context. Essentially the purpose is to visualize data from sensors.

&#x200B;

Key objects include patients, sensors, and clinics (treatment sites)....in addition there will be different User types that need to be implemented.

&#x200B;

So i'm wondering how I should go about structuring the project? Should every item needing CRUD operations be its own separate app, or should eeeevrrything be in one models.py file? What are the things I should be thinking about to answer these questions?

&#x200B;

/r/django
https://redd.it/1c6fhs8
Can't use div styles

/r/flask
https://redd.it/1c6em16
Deploying Multi-Module Python Applications on GCP: Service Recommendations?

I'm working on a project involving a Python application with multiple interacting modules and am looking for some advice on deploying it efficiently on Google Cloud Platform. Here's a brief overview of what the application entails:


Functionality Overview:
Data Fetching: One module fetches data from external websites.
Data Extraction: Another module extracts data from another GCP project.
Data Processing: Variables are processed across various modules.
CSV Output: The app generates and stores CSV files.
Scheduled Running: The application should run automatically once daily.


I would greatly appreciate your insights on the following questions:
1. What are the best GCP services to use for this type of application?
2. Recommended Python libraries for handling web data retrieval in this case?
3. How to proceed step by step? I intend to first deploy my Python application using placeholder inputs and simple printed outputs. Then, I plan to integrate the data fetching component and implement the creation and storage of CSV files. Does this strategy seem logical to you?


Currently, I only tried to deploy my Python code using Google Cloud Functions, but I find this method impractical because I must deploy each module separately.

/r/Python
https://redd.it/1c6b77i
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1c6pauh
Monitoring asyncio ready queue in python

I'm optimizing the performance of a Python application that includes many non-blocking I/O operations, some of which involve making HTTP API calls. We use an asynchronous client for all I/O operations, including database and Redis access. During load testing with concurrent users, we've noticed that processing times significantly increase with the number of users. How can we determine if this slowdown is due to delays in API calls or if there is a significant delay in the event loop picking up tasks that have been resolved and added to the ready queue?
I have tried setting up an async task which runs continuously with an asyncio.sleep(2) and measures the time difference between the actual time and 2 seconds, thus giving me a proxy of what is the delay at that moment. This worked fine even though with some overhead of running a task every 2 seconds and it's still a proxy. Instead, I'm looking for ways to monitor this on explicit async tasks.

/r/Python
https://redd.it/1c6qpbo
Windows Chrome and Firefox Cookie Extractor

# Windows Chrome and Firefox Cookie Extractor

## What my project does

The Chrome and Firefox Cookie Extractor is a Python script that allows you to extract cookies from both Chrome and Firefox browsers. It provides a convenient way to retrieve cookie information, including the domain, name, value, expiration date, and other attributes. The script supports three output formats: Netscape, JSON, and plain text.

## Target Audience

This project is intended for developers, security researchers, and anyone who needs to extract and analyze cookie data from Chrome and Firefox browsers. It can be useful for various purposes, such as:

- Debugging and testing web applications
- Analyzing user behavior and tracking
- Identifying potential security vulnerabilities
- Automating cookie extraction for data analysis

## Comparison

Compared to other cookie extraction tools, this script offers several advantages:

1. Dual-browser support: It supports both Chrome and Firefox, allowing you to extract cookies from either browser or combine cookies from both browsers into a single output file.

2. Multiple output formats: The script provides three output formats (Netscape, JSON, and plain text) to cater to different requirements and preferences.

3. Customizable output: You can specify the output file path and choose the desired output format using command-line arguments.

4. Easy to use: The script is simple to

/r/Python
https://redd.it/1c6n8sw
How to Exclude mediaroot and media Folders from git repository using gitignore file ?

**How to Exclude media\
root and media Folders from git repository using .gitignore file ?

&#x200B;

/r/djangolearning
https://redd.it/1c6ezeb
Achieve true parallelism in Python 3.12

Article link: https://rishiraj.me/articles/2024-04/python\_subinterpreter\_parallelism

I have written an article, which should be helpful to folks at all experience levels, covering various multi-tasking paradigms in computers, and how they apply in CPython, with its unique limitations like the Global Interpreter Lock. Using this knowledge, we look at traditional ways to achieve "true parallelism" (i.e. multiple tasks running at the same time) in Python.

Finally, we build a solution utilizing newer concepts in Python 3.12 to run any arbitrary pure Python code in parallel across multiple threads. All the code used to achieve this, along with the benchmarking code are available in the repository linked in the blog-post.

This is my first time writing a technical post in Python. Any feedback would be really appreciated! 😊

/r/Python
https://redd.it/1c6sdyj
Anyone use django-vite? Trying to figure out best approach to SEO

Building a website for a company I’m starting with some others. I chose the stack of django REST server using DRF and a React SPA frontend with Vite. Everything is working great but we recently were talking SEO (and meta data) and realized my stack choice isn’t the best but I’m essentially done with the mvp and want to see if I can figure out a solution without having to rip out too much. Already debating moving everything to Nextjs since I’m a big React person.

I know Google and others can scrape JavaScript now but I also know that SSR is a faster delivery for better SEO scores and also metadata (like sending a link on a social media and preloading info about it) is very important.

I stumbled upon a supported package called django-vite which seems to bring Vite into django and handle the webpack stuff. I’m assuming this will do the SSR of my application with Vite/react and I can then just ditch my hosted SPA or would I just be doing the same thing but extra steps?

Does anyone else have any tips on how to best handle my situation?

Reason I went with django instead of

/r/django
https://redd.it/1c6skwc
How to find remote position?

Hello guys,

I'm a Django developer that's looking into working remotely / freelancing as a full stack Django developer.

I work in DevOps so I have a good knowledge of Linux, Docker, Cloud, etc.. but in my free time I practice full stack Django development and would like to make some money with that either by getting another remote job or by freelancing.

Where do you find clients when first starting to freelance? Are there any specific Django sites or groups?

All advice is appreciated!

/r/djangolearning
https://redd.it/1c4ix7w
Seeking Advice: Automating Tasks with Python Under Strict IT Restrictions

I’m currently a Computer Science student and work as an Applications Support Engineer.

I have been encountering a lot of manual and repetitive tasks at my job that I’m eager to automate to improve my productivity.

However, theres a lot of IT restrictions on my work laptop. Even the developers on another team face similar challenges and end up using their personal devices for certain tasks due to these limitations.

Previously, in a different role within the same company, I successfully automated tasks using Excel Power Query, Excel VBA, and Power Automate. I’m new to Python and would like to leverage it for automation as well, but I’m unsure how to navigate the IT restrictions.

Does anyone have experience or advice on how to deal with such situations? Any workarounds or tips on using Python in a restricted IT environment would be greatly appreciated!

Thank you in advance for your help!

/r/Python
https://redd.it/1c6y1av