TF includes a simple command line interface which is similar to the Linux or DOS/PowerShell prompt. You can cp or mv files, you can cat them or less them, and you can run a dir or a grep.
You can find it at https://github.com/patbeirne/tf
Here's a sample session:
There is also a sed command, which allows you to edit files inline. It's not an interactive editor, but it's handing for changing a constant or two in your .py code.
Code: Select all
>>> import tf simple shell: cp/copy mv/move rm/del cat/list cd dir/ls mkdir rmdir grep sed help /$ cp mail.log m.log.bak /$ dir -rwx all 230 boot.py -rwx all 2886 m.log.bak -rwx all 2886 mail.log -rwx all 2401 main.py -rwx all 2259 main_test.py -rwx all 99182 mqtt.log -rwx all 6949 tf.py -rwx all 15 webrepl_cfg.py disk size: 392 KB disk free: 196 KB /$ cat -n -l 1000-1005 mqtt.log ====mqtt.log===== 1000 1616120701: Client mosq-d911rjWHX3Rdwcntoo disconnected. 1001 1616124181: New connection from 18.104.22.168 on port 1883. 1002 1616124181: New client connected from 22.214.171.124 as mosq-kwcmiGmZ7jlEVRecrU (c1, k60). 1003 1616124181: Client mosq-kwcmiGmZ7jlEVRecrU disconnected. 1004 1616126374: Socket error on client DVES_98843E, disconnecting. 1005 1616126425: Client DVES_83244E has exceeded timeout, disconnecting. /$ grep 24.114.80.\d+ mqtt.log 977 1616120273: New connection from 126.96.36.199 on port 1883. 980 1616120273: New client connected from 188.8.131.52 as Rutherford1616120233590 (c1, k60, u'patb'). 1046 1616142039: New connection from 184.108.40.206 on port 1883. 1049 1616142039: New client connected from 220.127.116.11 as Rutherford1616120233590 (c1, k60, u'patb'). /$
This project is 100% upython code, and lives in two files: tf.py and tf_extend.py. The module is written such that you can extract just the file_copy, file_grep and file_sed functions if that's all you need.
It's still early days in this project, so I'm open to suggestions:
- other command line options or changes in syntax
- would it be useful to pipe grep output to a file?
I find this module handy for visualizing the contents of the flash file system, cleaning up unused files and making backups of versions before trying changes.
If you do get as far as checking this out, scroll to the bottom of the README and look for 'extensions' where I put in some fun extra tools.