pyfs: Python File Server

python powered
Remote sessions and file-transfer between cell phones, PC and XBOX, running Python
Version 0.3

What's pyfs?

Pyfs is a (sort of) python replacement for shell+rsh+ftp+telnet, in a very alpha development stage. Pyfs works on every platforms supporting Python, with network connections in mind. Having the pyfs server running on the machine A (a PC, a Nokia phone with Symbian S60, an XBOX console), you can connect to A from another machine B (using the pyfs client), either via TCP, either via Bluetooth. After the connection is established, you can interact with the remote python shell on A, or also start a form of UNIX-like shell on A, with commands like cp, rm, ls, mkdir, etc, and even  transfer files, in both directions.

The name is pyfs because pyshell is already used by another program.

PyFS is written in a minimal Python, with the portability in mind. The programming style is poor, maybe just acceptable?, and the program  crashs at the end.  Other  bugs are in progress. And, yes: it basically works.

Thank You for suggestions and improvements.

Download

here

Platform/OS tested

  1. Linux ( with Python 2.4.2)
  2. Nokia N70 (with py60, the Python for Symbian-60 machines)
  3. XBOX (with xbmc and Python)
  4. Win32 (PC running win xp)

Network stacks supported

TCP/IP over ethernet for XBOX, LINUX e Win32; Bluetooth for Symbian (using bluez  BT stack on the linux side).
Network communication is pyfs is realized  using simple sockets (see my implementation in stream.py). I wrapped every socket call in a python class called stream. The stream class transfers data using small chunks, adding control check (CRC32) and other machinery.

Pyfs as remote python console

Pyfs is a server/client command-line suite. As example scenario, we  run "server.py" on the N70 cell phone and connect to it from a Linux box via Bluetooth, but the same should happen for other hardware.

If the address of your phone is, for example, 00:16:4E:D3:75:55, and the its BT channel is 13, you must run the client on the linux box executing the command:

# client.py 00:16:4E:D3:75:55 13

(in windows, you must write python client.py, instead, etc)

After that, you will have the usual python prompt from the cell phone:


Connecting to 00:16:4E:D3:75:55, via BT port 13
peername ('00:16:4E:D3:75:55', 13)
ok.
Proto=CRC32; platform symbian_s60; mode=BT; port=13
Python version: 2.2.2 (#0, Sep 26 2005, 11:38:57)
[GCC 2.9-psion-98r2 (Symbian build 546)]
Server ready; please, tupe stuff.
>>

Now  You can interact with the  powerfull Python environment in the usual way (see the Python manual).
In order to avoid confusion, the python prompt in pyfs is ">>" and not ">>>".

Pyfs as remote unix-like shell

After you have the python prompt, you can run the special python command sh():

>> sh()

and the shell will start:

>> sh()
UNIX-LIKE Shell, Platform: symbian_s60
Help: write 'help', or 'man command'
Quit with 'exit'

sh> pwd
E:\System\apps\Python\
sh> ls
ball.py imgviewer.py Python_aif.mif
bt_console.py interactive_console.py Python.app
default.py keyviewer.py Python.rsc
fibo.py my/ series60_console.py
filebrowser.py phpush.py snake.py
sh>



Now you can remove files (rm), copy files and directory recursively (cp), and all the other stuff you usally  expect in a UNIX-like shell.  See man pages.

Notes about the pyfs shell

The shell built-in in pyfs is absolutely not-complete, but it supports wildcards, regular-expressions,
manual pages,with the 'man' commands:

# man cp

The pyfs shell supports the commands history, if your python "readline" module supports the feature (for example, Linux does).

Examples:

# cd E:\
# mkdir tmp\img
# cp -r E:\Images\*.jpg E:\sounds\*.mp3 E:\tmp
# ls E:\system\libs\*.dll
# rm -r E:\tmp 

Pyfs as file-server

Being under the shell, you can trasfer files from server and client using
the two commands:


I used different names from those  used in the FTP/SSH world, in order to avoid confusion.

Examples:

# rx /home/michele/devel/pyfs/*.py .
# tx *.jpg *2006*.jpg    /tmp/nokia

Pyfs as stand-alone shell

If you just have no xbox console, no Nokia phones with python, no linux boxes, you can still use pufs as stand-alone shell of file-transfer program.

To run pyfs as stand-alone shell, please execute the command:

  # shell.py

GPS

A simple (experimental) utility called gps, allow you to connect via bluetooth to some GPS device and to
dump some gps NEMEA data.

Nokia specifics

For Nokia Serie 60 phones, pyfs have additional shell commands

See "man" pages.

Installation

Command-line options: server.py

Basically, the server can start in two modes: the BT (bluetooth mode), and the TCP mode. The server needs an additional parameter: the port.  If mode=TCP, the port is the usual TCP/IP port (default used in pyfs: 1025). If mode=BT, the port is the bluetooth channel (default used py pyfs: 13)
      
        # server.py       (default options)
        # server.py port
        # server.py BT|TCP port

Without paramenters, server.py do a sort of autodetection: it starts in BT mode (channel 13) if you starts it on the cell phone; TCP mode in the other cases.

Command-line options: client.py

The synopsis for client.py :
      
 # client.py address port

Examples:

Credits

For this little project I used code and suggestions from a lot of people over Internet.  Thanks to the Authors of pyshell, putools, and to the Authors of several good python tutorials I found, such mobilenin and the developers of the Python Symbian porting. You can find these materials by using google. Sorry, I don't remember the URLs.

Thanks to Sunsite.dk to host again a project of mine.

Disclaimers

The code is released as is, without any kind or warranties.
The code is released under the GPL license.
Sorry for the fractured english used here and in the coding.

Contacts

For suggestions about improvement please contact:

Michele Andreoli michele.andreoli (at) katamail.com
Pisa, Italy

December 2006