Running Python on Android

I've been working on my latest pet projects about tracking and charting your Hive Portfolio over time (about which I'll post tomorrow, with some significant updates).

In the meantime, I've been trying to solve a problem I had. Since I'll be on vacation most of next week (yeah... short and sweet, hopefully), and I don't have a server that runs 24/7, I had to come up with a plan regarding how will I run my portfolio tracking script on the days while I wasn't home to power up the laptop.

My first thought when I started developing this tool was to simply not track those days when I wasn't around to power up the laptop. That... was an option. But, encouraged by the versatility of AI to help out with different tasks (even though you often hit the wall and YOU are the one that needs to change strategy, make adjustments, and so on), I thought... ok, let's see if I can make this work when I'm not home. After all, many things have changed ("upgraded") from my initial thoughts about this tool.

So... a few days ago, I had the idea: what if I left the laptop in suspended mode (S3, for those who know). Would I be able to wake it up, run the script and put it back to suspended mode? Turns out I couldn't. I couldn't use rtcwake to do it because my system doesn't support waking by RTC alarms (alarm_irq is set to "no").

Next step was to check BIOS. And yes, I found there something even better: auto-waking on S5 (i.e. on powering up). But again... a dead end. What is likely a custom BIOS for my Lenovo ThinkBook, hid that option the next time I tried to look for it, after I enabled it. Turns out it can be a standard behavior for them. No trick worked to show advanced options again.

There was still the option "Wake on LAN" which could be used, but I got tired of going that route. Plus, I found this option... risky to pursue anyway. It's worth mentioning that the AI didn't mention anything about risks (but I didn't ask it to either). So, be careful about following AI's instructions without critical thinking.

So... in the end, I gave up on a scheduled power up, running my script, and powering down process, which would have been cool, but... well, maybe it works on certain systems or if one has time to tinker with the options until they find a way they are comfortable with.

I, however, switched.

If I can't run my script at home... then let's take the script with me and run it. Ok... Since I don't take my laptop on vacations (that's probably obvious by what I wrote already), I needed my script to run on my phone.

That was a big if. Would Python run on Android? To be honest, when I asked this question to the AI, I expected a negative answer. I was relieved when it started with "Sure!". It surely knows how to say the "right" words at the beginning, lol.

Anyway, the solution suitable for me is... F-Droid + Termux + Python.

Screenshot_20250716-112944_Termux.jpg
Screenshot from Termux terminal emulator.

F-Droid is an open-source app store for Android (it requires no "special" rights to your phone). Termux is the Terminal emulator and Linux environment app, from where you can install packages, run shell scripts, etc. That's where I installed Python from and other packages I needed for my script (didn't have space to create a Python virtual environment too—due to storage shortage, I'll uninstall everything when my vacation is over anyway). Termux only needs access to media and files, if YOU activate that option, and I needed it, to be able to save snapshots outside the sandbox.

So... I created a custom Hive Portfolio Tracker version for Android with reduced functionality (no automation), tested it on my phone and it works! Now all I have to do is to remember to run the script daily while on vacation. Hopefully, I will. I put a lot of work into this for me to forget it next week, while doing my limited daily tasks.😀



0
0
0.000
25 comments
avatar

It's impressive how you turned a challenge into an opportunity, running the script from your phone during vacation is a smart and resourceful solution!

0
0
0.000
avatar

I needed a solution and eventually found one. Glad I did!

0
0
0.000
avatar

Yeah I can't see many other ways unless you leave the pc turned on with scheduled operations

Doesn't the Android app slow down your phone? Anyways enjoy your vacation

0
0
0.000
avatar

Yeah I can't see many other ways unless you leave the pc turned on with scheduled operations

That was another option too. But too much electricity consumed for 5 minutes of work. And I don't like leaving anything non-essential turned on while I am on vacation. I don't want any bad surprises when I come back.

Doesn't the Android app slow down your phone?

I don't keep it open unless I use it and it doesn't seem to run in the background. I haven't noticed any degradation of my phone usage, even though I have almost full storage, with nothing much except these apps I can uninstall or remove. Looks like I will be forced to upgrade soon, even though I don't particularly like doing so.

Anyways enjoy your vacation

Thanks.

0
0
0.000
avatar

Have a great vacation in advanced, hopefully will be be 5$ when you get back 😅😅😅

0
0
0.000
avatar

Thanks!

hopefully will be be 5$ when you get back 😅😅😅

Not so steep man, I won't be able to enjoy my vacation keeping my eyes on the charts, lol.

0
0
0.000
avatar

Then maybe all you need is to switch off the Internet lol

0
0
0.000
avatar

I'm just joking. It can go as high and quickly as it wants to. I'm sure everyone will be happy, including myself.

0
0
0.000
avatar

Termux has saved my bacon more than once in my life. :D

0
0
0.000
avatar

I read good things about it and it certainly was what I needed in the context. Thanks for dropping by!

0
0
0.000
avatar

Congratulations @gadrian! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 30000 HP as payout for your posts, comments and curation.
Your next payout target is 31000 HP.
The unit is Hive Power equivalent because post and comment rewards can be split into HP and HBD

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

0
0
0.000
avatar

By working hard through coding, we can now create anything. If we have knowledge about this thing, we will wait for your project.

0
0
0.000
avatar

Yep, most likely, I will post about it today. I still have a few things to wrap up for that, and if nothing unexpected happens (I don't expect to, but we rarely do), this should be ready for a new "shipment", with some fixes for old bugs too.

0
0
0.000
avatar

I hope it works, but I think it should work out. Python doesn't take that much resources, and it should only take a small amount of time to process all of that.

0
0
0.000
avatar

Yep, it works! I already tested it after I set up everything.

0
0
0.000
avatar

Am amazed

You're like the first person aside myself that I've seen programming with termux on Android...

Good luck and welldone

0
0
0.000
avatar

I needed a way to run my Python script on mobile. That's the solution I found that worked in my case. Won't use Termux to code (although it probably could), all I need it for is to run my Python script.

0
0
0.000