How to install twistedweb python library on a web server - python

I have a small application written in python using TwistedWeb. It is a chat server.
Everything is configured right now as for localhost.
All I want is to run this python script on a server(shared server provided by Fatcow.com).
I mean that the script will be working all the time and some clients will connect/disconnect to it. Fatcow gives me python 2.5 without any custom libraries. Is there a way and a tutorial how to make it work with TwistedWeb?
Thanks in advice.

the easy_install/pip modes of installation are very likely to fail because of broken dependencies. You will have to download the tar and build it yourself. See the attached link for more info on installing the same on CENTOS.
http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#CanIinstallTwistedusingeasy_installorpip

I have contacted Fatcow.com support. They do not support SSH connections and do not support Python 2.7 with Twisted library, especially python socket application as server. So it is dead end.
Question resolved.

Related

Update strategy Python application + Ember frontend on BeagleBone

For the moment I've created an Python web application running on uwsgi with a frontend created in EmberJS. There is also a small python script running that is controlling I/O and serial ports connected to the beaglebone black.
The system is running on debian, packages are managed and installed via ansible, the applications are updated also via some ansible scripts. With other words, updates are for the moment done by manual work launching the ansible scripts over ssh.
I'm searching now a strategy/method to update my python applications in an easy way and that can also be done by our clients (ex: via webinterface). A good example is the update of a router firmware. I'm wondering how I can use a similar strategy for my python applications.
I checked Yocto where I can build my own linux with but I don't see how to include my applications in those builds, and I don't wont to build a complete image in case of hotfixes.
Anyone who has a similar project and that would like to share with me some useful information to handle some upgrade strategies/methods?
A natural strategy would be to make use of the package manager also used for the rest of the system. The various package managers of Linux distributions are not closed systems. You can create your own package repository containing just your application/scripts and add it as a package source on your target. Your "updater" would work on top of that.
This is also a route you can go when using yocto.

Installing XMPP on a Python server

I am attempting to follow set up the python xmpp server for GCM as detailed here:
https://developer.android.com/google/gcm/ccs.html
The website I used for hosting is pythonanywhere.com
My issue is that when I saw import xmpp, it says that no such module is found.
Should I be trying to install it on their server? I realize that this issue is probably really basic, but I have looked online for the last hour or so without much fruit. I see all these variations on XMPP and am not sure if I have to deal with any of those or if I can just do exactly what the google demo is saying.
Thanks for your time,
-Alper
PythonAnywhere doesn't support raw TCP socket connections or websockets, so XMPP may not work. But then again, from reading wikipedia, it does look like there's a pure-HTTP alternative, so it might work.
Check out this guide to installing new modules: https://www.pythonanywhere.com/wiki/InstallingNewModules. My suggestion would be to use a virtualenv for your web app, and install flask and xmpp into that...
You will have to download and install the missing python package. You may do this manually via SSH if the provider gives you access, or there may be a way to include a requirements document such that the server looks and downloads needed packages automatically. It all depends on the host, the access they allow you, and their automation features.

Simple python response to ajax without webframework

I am attempting to make a dynamic website for a school project. The problem is it has to be on the school server and I can't use any webframeworks. I have searched through google and stackoverflow but I can't seem to get an answer.
I have tried the code that was provided here:
How to implement a minimal server for AJAX in Python?
It worked on the local server but how can I change it so that it would open on the school server. When I used those codes, the page won't load or an internal error shows. Can someone point me in the right direction?
Using a web framework in python does not necessary needs a system package installation (like running a sudo apt-get install python-something).
In the end python frameworks are just files like in your project, but you can install them system wide (like in the apt-get example) or ship them within your project (probably what you want). Take a look at virtual environment for creating a self contained environment and setuptools foi packaging the application and its dependencies
For implementing an ajax server directly in python without a wsgi container (apache, nginx, etc) I recommend using flask. It is very, very simple and very powerful

Using Twisted on a server without installation privileges?

I have a server that I'd like to use to maintain persistent connections with a set of devices, just so that they can pass simple messages back and forth. It's a trivial task, but selecting a server-side platform has been suprrisingly difficult (especially since I have no administrative privileges - it's a dedicated commercial server).
My best idea so far is to write a TCP server in Python. The Twisted platform seems suitable for the task, and has a lot of good reviews. However, my server has Python 2.7 but not Twisted, and the admins have been reluctant to install it for me.
Is there any way that I can just upload a Twisted package to the server and reference it in my libraries without installing it as a framework?
I'm not sure what you mean by "installing it as a framework". If you are using an OS X server hosting environment, then maybe you're talking about Framework with a Capital F. However, OS X server hosting isn't a very common environment so I'm guessing that's not it.
If you just want to know how to install a Python library in your home directory, then the general answer is:
$ python setup.py install --user
This Just Works™ on Python 2.7 (assuming the package uses distutils, which Twisted does, and you unpack the source .tar.gz and change your working directory to the directory that is the root of the contents of that .tar.gz), so you should be done after that.
Use virtualenv to create your private Python libraries installation.

Setup Python environment on Windows

How do I setup a Python environment on windows computer so I can start writing and running Python scripts, is there an install bundle? Also which database should i use?
I should of mentioned that I am using this for web based applications. Does it require apache? or does it use another http server? What is the standard setup for Python running web apps?
Download the Python 2.6 Windows installer from python.org (direct link). If you're just learning, use the included SQLite library so you don't have to fiddle with database servers.
Most web development frameworks (Django, Turbogears, etc) come with a built-in webserver command that runs on the local computer without Apache.
Bundle: go with Activestate's Python, which bundles many useful win32-related libraries. It has no version 2.6 yet, but most code you'll find online refers to 2.5 and lower anyway.
Database: any of the popular open-source DBs are simple to configure. But as John already suggested, for simple beginning stuff just use SQLite which already comes bundled with Python.
Web server: depends on the scale. You can configure Apache, yes, but for trying simple things the following is a quite complete web server in Python that will also serve CGI scripts writte in Python:
import CGIHTTPServer
import BaseHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ["/cgi"]
PORT = 9999
httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
I strongly recommend ActiveState Python for python on windows development. It comes with Win32Com and various other goodies, has a mature and clean installer, a chm version of the docs and works really well. I use this all of the time.
As for a database, Activestate comes with odbc support, which plays very nicely with SQL server. I've also had it working with Sybase and DB2/400 (although the connection strings for the latter tend to be rather convoluted). For Oracle, I recommend CX_Oracle as the best interface library. Native drivers for most proprietary and open-source databases (such as MySQL and PostGreSQL) also exist. Recent versions of Python (from 2.5 onwards IIRC) come with SQLite bundled as standard.
Don't forget to install pywin32 after installing the official (command line) installer. This will define additional start menu items and the highly useful PythonWin IDE.
An installer for both is available at Activestate (no 2.6 yet). The Activestate distribution contains additional documentation.
Might I suggest taking a look at Karrigell? It's really a nice Python web framework if you don't require everything Django and Turbogears offers. It might be easier for you to work with web frameworks until you get comfortable with them.
For development, I recommend downloading the latest SPE IDE. It should provide you nearly all the tools you will need, plus it includes wxGlade for GUI development.
Django tutorial How to install Django provides a good example how a web-development Python environment may look.

Categories

Resources