Search Results

Search found 15187 results on 608 pages for 'boost python'.

Page 108/608 | < Previous Page | 104 105 106 107 108 109 110 111 112 113 114 115  | Next Page >

  • Downloading file with Python results in only 4.1kB

    - by Vlad Ogay
    I'm using simple code: import urllib2 response = urllib2.urlopen("http://www.mysite.com/getfile/4355") output = open('myfile.zip','wb') output.write(response.read()) output.close() The web-server is IIS + ASP.NET MVC 4 It returns FileResult wrapping a zip-file with "application/octet-stream" content-type. The problem is that downloaded zip file is broken - only 4.1kB size, where it must be 24kB. When I type the url adress in web-browser directly - it downloads and opens fine. Could you please, suggest, what's wrong with my Python code?

    Read the article

  • Python timed file upload

    - by Ali
    I have a python script that accepts a file from the user and saves it. Is it possible to not upload the file immediately but to que it up and when the server has less load to upload it then. Can this be done by transferring the file to the browsers storage area or taking the file from the Harddrive and transferring to the User's RAM?

    Read the article

  • How do I forward a request to a different url in python

    - by tax
    import SimpleHTTPServer import SocketServer class myHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_GET(self): print self.path if self.path == '/analog': return "http://someserver.com/analog" return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) theport = 1234 Handler = myHandler pywebserver = SocketServer.TCPServer(("", theport), Handler) print "Python based web server. Serving at port", theport pywebserver.serve_forever()

    Read the article

  • Lisp's "some" in Python?

    - by Mark Probst
    I have a list of strings and a list of filters (which are also strings, to be interpreted as regular expressions). I want a list of all the elements in my string list that are accepted by at least one of the filters. Ideally, I'd write [s for s in strings if some (lambda f: re.match (f, s), filters)] where some is defined as def some (pred, list): for x in list: res = pred (x) if res: return res return False Is something like that already available in Python, or is there a more idiomatic way to do this?

    Read the article

  • Google Apps shared contacts API get a contact for python

    - by Mike
    I'm having some issues trying to pull a shared contact using the gdata api for python that Google provides. Here is what I have to get the contacts.. but they are not all listed there feed = gd_client.GetContactsFeed() for i, entry in enumerate(feed.entry): print entry.title I can't figure out how to pull out a single contact so I can edit the contact information.. thanks!

    Read the article

  • Wav analysis in python

    - by mudder
    I'm looking for a python library that will help me analyze the audio in wav files. At the very least I'm hoping to find some kind of interface that understands .wav format so that I don't have to :P at best I need a module with methods for reading wave form parameters like pitch, volume levels, etc

    Read the article

  • Best Python IDE for my situation

    - by ChrisC
    I want to write a database app in Python, using SQLite and wxPython. My only "experience" is 1 class on basic C++ console programming and OOP concepts. Which IDE would be best for my situation? In case it matters, I only need my new program to run on Windows, and I do want to make it "portable". Thank you.

    Read the article

  • Trappings MySQL Warnings on Calls Wrapped in Classes -- Python

    - by chernevik
    I can't get Python's try/else blocks to catch MySQL warnings when the execution statements are wrapped in classes. I have a class that has as a MySQL connection object as an attribute, a MySQL cursor object as another, and a method that run queries through that cursor object. The cursor is itself wrapped in a class. These seem to run queries properly, but the MySQL warnings they generate are not caught as exceptions in a try/else block. Why don't the try/else blocks catch the warnings? How would I revise the classes or method calls to catch the warnings? Also, I've looked through the prominent sources and can't find a discussion that helps me understand this. I'd appreciate any reference that explains this. Please see code below. Apologies for verbosity, I'm newbie. #!/usr/bin/python import MySQLdb import sys import copy sys.path.append('../../config') import credentials as c # local module with dbase connection credentials #============================================================================= # CLASSES #------------------------------------------------------------------------ class dbMySQL_Connection: def __init__(self, db_server, db_user, db_passwd): self.conn = MySQLdb.connect(db_server, db_user, db_passwd) def getCursor(self, dict_flag=True): self.dbMySQL_Cursor = dbMySQL_Cursor(self.conn, dict_flag) return self.dbMySQL_Cursor def runQuery(self, qryStr, dict_flag=True): qry_res = runQueryNoCursor(qryStr=qryStr, \ conn=self, \ dict_flag=dict_flag) return qry_res #------------------------------------------------------------------------ class dbMySQL_Cursor: def __init__(self, conn, dict_flag=True): if dict_flag: dbMySQL_Cursor = conn.cursor(MySQLdb.cursors.DictCursor) else: dbMySQL_Cursor = conn.cursor() self.dbMySQL_Cursor = dbMySQL_Cursor def closeCursor(self): self.dbMySQL_Cursor.close() #============================================================================= # QUERY FUNCTIONS #------------------------------------------------------------------------------ def runQueryNoCursor(qryStr, conn, dict_flag=True): dbMySQL_Cursor = conn.getCursor(dict_flag) qry_res =runQueryFnc(qryStr, dbMySQL_Cursor.dbMySQL_Cursor) dbMySQL_Cursor.closeCursor() return qry_res #------------------------------------------------------------------------------ def runQueryFnc(qryStr, dbMySQL_Cursor): qry_res = {} qry_res['rows'] = dbMySQL_Cursor.execute(qryStr) qry_res['result'] = copy.deepcopy(dbMySQL_Cursor.fetchall()) qry_res['messages'] = copy.deepcopy(dbMySQL_Cursor.messages) qry_res['query_str'] = qryStr return qry_res #============================================================================= # USAGES qry = 'DROP DATABASE IF EXISTS database_of_armaments' dbConn = dbMySQL_Connection(**c.creds) def dbConnRunQuery(): # Does not trap an exception; warning displayed to standard error. try: dbConn.runQuery(qry) except: print "dbConn.runQuery() caught an exception." def dbConnCursorExecute(): # Does not trap an exception; warning displayed to standard error. dbConn.getCursor() # try/except block does catches error without this try: dbConn.dbMySQL_Cursor.dbMySQL_Cursor.execute(qry) except Exception, e: print "dbConn.dbMySQL_Cursor.execute() caught an exception." print repr(e) def funcRunQueryNoCursor(): # Does not trap an exception; no warning displayed try: res = runQueryNoCursor(qry, dbConn) print 'Try worked. %s' % res except Exception, e: print "funcRunQueryNoCursor() caught an exception." print repr(e) #============================================================================= if __name__ == '__main__': print '\n' print 'EXAMPLE -- dbConnRunQuery()' dbConnRunQuery() print '\n' print 'EXAMPLE -- dbConnCursorExecute()' dbConnCursorExecute() print '\n' print 'EXAMPLE -- funcRunQueryNoCursor()' funcRunQueryNoCursor() print '\n'

    Read the article

  • How to handle redirects while parsing HTML? - Python

    - by RadiantHex
    Hi folks, I'm trying to submit a few forms through a Python script, I'm using the mechanized library. This is so I can implement a temporary API. The problem is that before after submission a blank page is returned informing that the request is being processed, after a few seconds the page is redirected to the final page. I understand if it might sound a bit generic, but I'm not sure what is going on. :) Any ideas?

    Read the article

  • Python ftplib - any way to shut it up?

    - by JamieH
    I am writing a test harness in python and as part of the testing I need to initialise an FTP server and upload various files. I am using ftplib and everything is working ok. The only problem I have is that I am seeing loads of FTP text appearing in the console window intermixed with my test results, which makes scanning the results quite tricky. I haven't found a way to shut ftp lib up and stop this happening, does anyone know how to stop this?

    Read the article

  • creation of folders in python

    - by beena shamsudeen
    i want to create folders with the name of a pdf file for eg,abc.if it does not exists,i should create a folder with name abc_1...if abc_1 exists,i shud create abc_2.if both exxists,abc_3 and so on...the scripting is in python..can u help me??

    Read the article

  • Change array that might contain None to an array that contains "" in python

    - by vy32
    I have a python function that gets an array called row. Typically row contains things like: ["Hello","goodbye","green"] And I print it with: print "\t".join(row) Unfortunately, sometimes it contains: ["Hello",None,"green"] Which generates this error: TypeError: sequence item 2: expected string or Unicode, NoneType found Is there an easy way to replace any None elements with ""?

    Read the article

  • Accessing relative path in Python

    - by Aaron Hoffman
    Hi, I'm running a Mac OS X environment and am used to using ~/ to provide the access to the current user's directory. For example, in my python script I'm just trying to use os.chdir("/Users/aaron/Desktop/testdir/") But would like to use os.chdir("~/Desktop/testdir/") I'm getting a no such file or directory error when trying to run this. Any ideas?

    Read the article

  • Python pattern search in a string

    - by Hulk
    In python if a string contains the following, print valid_str The output of this is Record is positive in tone: It emphasizes "what a child can do and his or her achievements, as opposed to what he or she cannot do," explains the It is useful for progress and achievements during office conferences How to search for the pattern It is useful in the above string and if not found return something. Thanks..

    Read the article

  • python set difference

    - by user1311992
    I'm doing a set difference operation in Python: from sets import Set from mongokit import ObjectId x = [ObjectId("4f7aba8a43f1e51544000006"), ObjectId("4f7abaa043f1e51544000007"), ObjectId("4f7ac02543f1e51a44000001")] y = [ObjectId("4f7acde943f1e51fb6000003")] print list(Set(x).difference(Set(y))) I'm getting: [ObjectId('4f7abaa043f1e51544000007'), ObjectId('4f7ac02543f1e51a44000001'), ObjectId('4f7aba8a43f1e51544000006')] I need to get the first element for next operation which is important. How can I retain the list x in original format?

    Read the article

  • Running a batch file with parameters in python OR F#

    - by Ramy
    I searched the site but didn't see anything quite matching what I was looking for. I created a stand alone application that uses a web service I created. To run the client I use: c:/scriptsdirecotry "run-client.bat" param1 param2 param3 param4 how would I go about coding this in python or F#. seems like it should be pretty simple but I haven't seen anything online that quite matches what i'm looking for. Thanks in advance.

    Read the article

  • Python - Launch a Long Running Process from a Web App

    - by Greg
    I have a python web application that needs to launch a long running process. The catch is I don't want it to wait around for the process to finish. Just launch and finish. I'm running on windows XP, and the web app is running under IIS (if that matters). So far I tried popen but that didn't seem to work.

    Read the article

  • Python: Pass parameter one time, but use more times

    - by Gabriel L. Oliveira
    I'm trying to do this: commands = { 'py': 'python %s', 'md': 'markdown "%s" "%s.html"; gnome-open "%s.html"', } commands['md'] % 'file.md' But like you see, the commmands['md'] uses the parameter 3 times, but the commands['py'] just use once. How can I repeat the parameter without changing the last line (so, just passing the parameter one time?)

    Read the article

< Previous Page | 104 105 106 107 108 109 110 111 112 113 114 115  | Next Page >