Python: start and connect to a sftp server using paramiko

Categories: Python; Tagged with: ; @ February 20th, 2016 22:24

requirement:

  1. start a sftp server using python
  2. connect to the sftp server and list files

code:

Docker python hello world project

Categories: LinuxPython; Tagged with: ; @ January 26th, 2016 23:12

create a Dockerfile 
this image will install python and start a SimpleHTTPServer:

FROM ubuntu
ENV DEBIAN_FRONTEND noninteractive
CMD ["bash"]

RUN apt-get update
RUN apt-get install -y python

EXPOSE 8000
CMD python -m SimpleHTTPServer 8000

Build project
docker build -t myapp:latest .
run docker image
docker run -P myapp
-P for port forwarding:  Publish all exposed ports to random ports
check the web page
find port by:
docker ps -l

This project can be found here:
https://github.com/guoliang-dev/docker-hello-world-python

ssh to linux guest/virtual machine running virtualbox

Categories: Linux; Tagged with: ; @ January 23rd, 2016 16:07

Install / Start SSH in your guest Linux

sudo service ssh status

install open-ssh in case it’s not ready in your guest:

sudo apt-get install openssh-server

start the service if the service is stopped.

sudo service ssh start

Setup VirtualBox – port forwarding

virtualbox > edit settings for the guest vm:
network > port forwarding (e.g host 3022 -> guest 22)

SSH to the guest linux

ssh user@loalhost -p 3022

One line to share the current folder via HTTP

Categories: Python; Tagged with: ; @ November 7th, 2015 18:23
>python -m SimpleHTTPServer $PORT

Dropbox Python SDK 2.2.0 bug: commit_chunked_upload ?

Categories: Development NotesPython; Tagged with: ; @ August 2nd, 2015 23:04

Issue:  dropbox keep ignoring the first folder when committing a chunked upload:

After chunked uploading completed, commit the file by:

response = self.dropbox_client.commit_chunked_upload('/backup/docs.zip', upload_id, False)
remote_path = response['path']

My understanding was remote_path in the response should be same as the full_path I passed: ‘/backup/docs.zip’, however, the remote_path is: ‘docs.zip’. form client.py /commit_chunked_upload:

The full path to which the chunks are uploaded, *including the file name*.
If the destination folder does not yet exist, it will be created.

full path with filename, and it’ll be used by:

url, params, headers = self.request("/commit_chunked_upload/%s" % full_path,
                                    params, content_server=True)

a http request to : /commit_chunked_upload//backup/docs.zip will be sent. however, the actual server url is:

https://api-content.dropbox.com/1/commit_chunked_upload/auto/<path>

https://www.dropbox.com/developers/core/docs#commit-chunked-upload

Solution / workaround

1. fix the SDK :
Following CheckedUpload class,  the commit url can be generated by:

path = “/commit_chunked_upload/%s%s” % (self.client.session.root, format_path(path))

2. add ‘auto’ in the front of the remote path:

response = self.dropbox_client.commit_chunked_upload('auto/' + remote_path, upload_id, False)

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.