Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
inveratulo
May 14, 2002
wat
Here's my question:

I am currently developing a web application that functions as sort of a spreadsheet. The client-side displays a dynamic table that the user can interact with and it works with a server-side db (MySQL).

I already wrote the bulk of the program in java, but uses the clientside JVM for everything, and it has gotten unwieldy very fast. So now I'm considering rewriting the whole thing using Python as a backend, preferably with things that belong serverside on the server.

I have considered the following options:
CGI - no this just won't do. I need more than i/o streams and i'm not the best html/css programmer anyway
Jython - halfway to python, but still enough java to give me a headache. Plus there are some performance concerns.
Frameworks like Zope or Django - these seem to have some kind of barrier to entry, lot of gotchas and I'm not sure I want to deal with those headaches just yet.
Pyjamas - seemed like the best option at a glance, but I had problems getting the libraries to work properly; plus with one developer and no updates in a year I don't know if it is worth getting in to anymore.
Google Web Toolkit (ajax) - this would be my ideal frontend. Uses native browser calls so its fast but unfortunately it does not support non-java backends. I've snooped around looking for python implementations, but so far have come up empty handed.

At this point I'm kinda scratching my head. I really want to use Python for this project, but it looks like to do that I will have to use a real python web framework, which just seems like overkill for what was supposed to be a neat and tidy app.

I'm just on the lookout for implementations that fit my needs without too much overkill. I guess if it comes down to it, I can get knee-deep into Django and make it work; but I'm open to any and all other suggestions.

Any recommendations/suggestions/warnings?

inveratulo fucked around with this message at 08:24 on Nov 5, 2007

Adbot
ADBOT LOVES YOU

inveratulo
May 14, 2002
wat
I'm writing a little script to telnet around to different routers, but unfortunately the routers default to a little user interface (Netopia 3386) when establishing a telnet connection. Pressing ctrl-N drops the telnet window into a command line, but I cannot figure out how to send this control character through python. I've been using telnetlib just for proof of concept, but probably will use pexpect in my final program.

How do I send control characters through either telnetlib or pexpect?

inveratulo
May 14, 2002
wat

deimos posted:

Ok, this is a slight case of RTFM, because pexpect has a sendcontrol()

hmmm sendcontrol was the first thing I tried actually but I couldn't get it to work. I kept getting an attribute error:
AttributeError: 'spawn' object has no attribute 'sendcontrol'

Should I be creating my connection object differently? This is how I did it:
conn = pexpect.spawn('telnet ' + host)


edit: I had version 2.1 which did not have sendcontrol(). I updated and now it works, thanks! I propose a new acronym: UTFM - Update The loving Modules.

inveratulo fucked around with this message at 18:29 on Mar 15, 2008

inveratulo
May 14, 2002
wat
Okay so I need to create and use a multi-dimensional array of unknown size.
To create, I am doing:
code:
myArray = [[]]
But I am not sure how to append my data to this structure?

inveratulo
May 14, 2002
wat

No Safe Word posted:

Depends on what you want to do. If you're going to be doing math-like stuff, save yourself a headache and just start with NumPy from the get-go:
http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html

Otherwise, you can just start with a list, insert/append a new list, and so on.
code:
In [1]: myArray = []

In [2]: myArray.append([1,2,3])

In [3]: myArray.append([1,3,5])

In [4]: myArray.append([2,5,7])

In [5]: myArray
Out[5]: [[1, 2, 3], [1, 3, 5], [2, 5, 7]]

In [6]: myArray[2]
Out[6]: [2, 5, 7]

In [7]: myArray[1][1]
Out[7]: 3

Thanks for the suggestion; as it always turns out, I find a solution shortly after posting for help on something. I think I am going to just use a dictionary with tuple addressing, like so:
code:
myDict = {}
myDict[0,0] = "welp"
myDict[0,1] = "rofl"
and so on...

inveratulo
May 14, 2002
wat
I have been stumped trying to get this one piece of code to function properly. I am trying to use the pxssh library to execute commands on a remote shell. Whenever I try to put the sendline() commands in a for loop, it will run the first command, but just hang on the subsequent commands and never execute. I cannot for the life of me figure out why this is happening.

Can someone shed some light on this?

This works:
code:
conn = pxssh.pxssh()
... login stuff is going here
...
conn.sendline("ls -latr")
conn.prompt()
print conn.before
conn.sendline("hostname -a")
conn.prompt()
print conn.before
but this does not work:
code:
conn = pxssh.pxssh()
cmds = open("commandFile.txt",'r')
... login stuff is going here
...
for line in cmds:
  conn.sendline(line.strip())
  conn.prompt()
  print conn.before

inveratulo
May 14, 2002
wat
Yea I thought getters/setters were bad form in Python. Keep that java nonsense outta here son!

inveratulo
May 14, 2002
wat
We have an automated job that is creating hot backups of a couple dozen SVN repositories and storing them with revision numbers as a tar.gz. The files end up looking something like one of these: reponame-qa-567-608.tar.gz, testrepo-670.tar.gz, or somerepo-34-434.tar.gz

I wrote the following section of code as part of a recovery operation, that will take the filenames, strip the revisions, and move the directories so that the above repos would end up like: reponame-qa, testrepo, and somerepo

code:
#!/usr/bin/python
import os,sys,re
for line in os.popen('ls').readlines():
  tmpArray = []
  for word in line.split('-'):
    if re.compile('\D').match(word) != None: tmpArray.append(word)
  os.popen("mv -f "+line.strip()+" "+'-'.join(tmpArray))
At this point the labor is done, so I'm happy with it; but I would be interested to know if there is a more efficient solution, as sort of a thought exercise. I figured it was possible to iterate over the filenames and quit when the first number was hit, but the above solution was the quickest way I knew how to do it. Can anyone do it better?

Adbot
ADBOT LOVES YOU

inveratulo
May 14, 2002
wat
Goddamn guys thanks a ton! My attempt was truly infantile.

  • Locked thread