Sending files in Python [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am quite new to Python and recently I wanted to send some files using Python. I quickly found out about sockets. But I searched for ready-made solution, because I thought client-server communication is such a common use, there must exist some kind of library (or maybe it's just because of my Java background and I got used to it:D). All answers about sending files I found mentioned sockets and that 'you have to write a protocol yourself'.
So here's my question: is there any library, ready protocol for client-server communication in Python (preferably 2.7)?

twisted is a very common one:
http://twistedmatrix.com/trac/
http://twistedmatrix.com/documents/13.0.0/core/examples/

If you use sockets, you can use ssh and then do scp (secured copies). If you are moving files back and forth, that would probably be the easiest way.

Maybe zeromq is something for you! There are also python bindings available. And good examples for implementing a Publisher-Subscriber pattern are also well documented.

is there any library, ready protocol for client-server communication
Generally speaking, yes: sockets (which you already found), twisted (as pointed in another answer) etc.
I wanted to send some files using Python
Use ftp! You can start an FTP server using pyftpdlib and use ftplib as client.

Related

Can RocksDB handle multiple read-only clients? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I need a key-value database, like redis or memcached, but not in memory and rather on disk. After filling the database (which we do regularly and from scratch), I'd actually only need the get operation, but from many different processes (so Kyoto Cabinet and LevelDB do not work for me).
I need like 5 million keys and ~10-30gb of data, so some other simple databases don't work as well.
I can't find any information on whether RocksDB can handle multiple read-only clients; it's not straight-forward to build on my OS so I wanted to ask before doing that. If it can't, is there any database which would work? Preferably with an Ubuntu package and Python bindings ;-).
We're just using many-many small files now, but it really sucks, as we want easy backups, copying, etc. I also suspect this may cause slowdowns, but it doesn't really matter that much.
Yes, you should be able to run multiple read-only clients on a single RocksDB database. Just open the database with DB::OpenForReadOnly() call: https://github.com/facebook/rocksdb/blob/master/include/rocksdb/db.h#L108
The simplest answer is probably Berkeley DB, and bindings are a part of the stdlib: https://docs.python.org/2/library/anydbm.html

Nonblocking django? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
At work I'm not allowed to use perl for web services. Python is allowed however.
What I need to do is serve up the results of some very slow c++ binaries. Each exe takes up to 20 seconds to run. In perl I'd just use mojolicious's non blocking event loop ( an example.of which is given here. http://blogs.perl.org/users/joel_berger/2014/01/writing-non-blocking-applications-with-mojolicious-part-3.html )
How would one go about doing this with django and python?
Tornado using non blocking IO , the concepts are the same as in perl or node js event loop, multiple tasks per thread and so on.
Probably won't be possible with Django, as the entire framework will need to be built specifically for running inside an event loop. In an event-driven framework, slow operations (I/O for example) needs to be implemented using callbacks, so that the actual I/O can be offloaded to the event loop itself, and the callback only called when the operation has finished; Django is not implemented like this.
Take a look at Twisted — it is an event-driven networking engine for Python that also has some web application frameworks built on top of it.
Take a look at A clean, lightweight alternative to Python's twisted. I'd choose gevent for a web app, as it runs with uWSGI--the most versatile web server to run Python code.

Implementing POP3 server with Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have no experience doing anything like this, but I want to make a little email server that will only be accessed from the local machine through the Mail app in OS X. I know that the Mail app lets you connect to an email server with the POP3 protocol, and I have a reference manual on POP3 so I know how it all needs to work. I am just not sure of the best way to write this. I know python has smtpd, which I can use for receiving mail from the Mail app. Can I just use the SocketServer module, subclass BaseRequestHandler, read from the self.request socket until I get a CRLF, split the data by spaces, then use the first item in the list as keyword and apply the corresponding function to the rest of the list, and finally return the status + results? Or is it more complicated than that?
--EDIT--
I forgot to mention that I wanted to do this in pure python.
Implementing protocols and a working server is always more complicated than "just a few lines of code". Try twisted It has implementations for many internet protocols and working examples. Here's an example: http://pepijndevos.nl/twisted-pop3-example-server/
You can use pypopper python recipe to readily implement the pop3 server functionality.

Building a website that interacts with DB and/or XML [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking to get into web development. My goal is to create some interactive webpages that interact with MS SQL databases (read/insert/updates), and also possibly sites that interact with XML files.
I've got some basic understanding of Python and Perl scripting. Can someone point me in the right direction in either of those languages to accomplish what i'm looking to do, or if it's easier to accomplish in another language what would that be?
Apologies if my stated goal is too broad.
I'd strongly suggest you to look into some of the web development frameworks. They take care of many low-level tasks which is needed in order to build a solid web page. I'm not very familiar with perl, so I can only suggest Python frameworks, especially one of the my favourites - Django. It has very good documentation which is essential for the first-timer. I believe you should be fine as long as you follow the official documentation.
Good luck
You can use SQL Alchamy in python, and lxml or the default ElementTree xml module for simple cases.
I have done both for a webservice I maintain, and they work nice.
You can also use a web development framework. I personally suggest Flask based on that it is a lightweight framework as opposted to django for instance. However, depending on your exact use case the latter might be better.

What are some Python libraries written to demostrate Functional Reactive Programming? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
We handle huge data streams through our socket servers and in need of a non-block way to management callbacks to prevent race conditions.
Recently I came to know about functional reactive programming a method of programming and the solution is just what we are looking for.
There are examples in Haskell (reactive banana), ClojureScript and Javascript (bacon js), but none for python. Are there any libraries written for Python enabling Functional Reactive Programming? If there aren't any libraries, where is a good place to start? What are the possible challenges to write one?
There's an official Microsoft wip Rx (Reactive Extensions) implementation for Python called Rx.py.
This project targets Python 3.
I just checked the Wikipedia article on reactive programming, and in there, three modules are mentioned. You could check those out:
Trellis
Yoopf
Traits

Categories

Resources