Search Results

Search found 43 results on 2 pages for 'mridang'.

Page 2/2 | < Previous Page | 1 2 

  • Python __subclasses__() not listing subclasses

    - by Mridang Agarwalla
    I cant seem to list all derived classes using the __subclasses__() method. Here's my directory layout: import.py backends __init__.py --digger __init__.py base.py test.py --plugins plugina_plugin.py From import.py i'm calling test.py. test.py in turn iterates over all the files in the plugins directory and loads all of them. test.py looks like this: import os import sys import re sys.path.append(os.path.join(os.path.abspath(os.path.dirname(os.path.abspath( __file__ ))))) sys.path.append(os.path.join(os.path.abspath(os.path.dirname(os.path.abspath( __file__ ))), 'plugins')) from base import BasePlugin class TestImport: def __init__(self): print 'heeeeello' PLUGIN_DIRECTORY = os.path.join(os.path.abspath(os.path.dirname(os.path.abspath( __file__ ))), 'plugins') for filename in os.listdir (PLUGIN_DIRECTORY): # Ignore subfolders if os.path.isdir (os.path.join(PLUGIN_DIRECTORY, filename)): continue else: if re.match(r".*?_plugin\.py$", filename): print ('Initialising plugin : ' + filename) __import__(re.sub(r".py", r"", filename)) print ('Plugin system initialized') print BasePlugin.__subclasses__() The problem us that the __subclasses__() method doesn't show any derived classes. All plugins in the plugins directory derive from a base class in the base.py file. base.py looks like this: class BasePlugin(object): """ Base """ def __init__(self): pass plugina_plugin.py looks like this: from base import BasePlugin class PluginA(BasePlugin): """ Plugin A """ def __init__(self): pass Could anyone help me out with this? Whatm am i doing wrong? I've racked my brains over this but I cant seem to figure it out Thanks.

    Read the article

  • Remove padding in wxPython's wxWizard

    - by mridang
    Hi Guys, I'm using wxPython to create a wizard using the wxWizard control. I'm trying to a draw a colored rectangle but when I run the app, there seems to be a about a 10px padding on each side of the rectangle. This goes for all other controls too. I have to offset them a bit so that they appear exactly where I want them to. Is there any way I could remove this padding? Here's the source of my base Wizard page. class SimplePage(wx.wizard.PyWizardPage): """ Simple wizard page with unlimited rows of text. """ def __init__(self, parent, title): wx.wizard.PyWizardPage.__init__(self, parent) self.next = self.prev = None #self.sizer = wx.BoxSizer(wx.VERTICAL) title = wx.StaticText(self, -1, title) title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) #self.sizer.AddWindow(title, 0, wx.ALIGN_LEFT|wx.ALL, padding) #self.sizer.AddWindow(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, padding) # self.SetSizer(self.sizer) self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint(self, evt): """set up the device context (DC) for painting""" self.dc = wx.PaintDC(self) self.dc.BeginDrawing() self.dc.SetPen(wx.Pen("grey",style=wx.TRANSPARENT)) self.dc.SetBrush(wx.Brush("grey", wx.SOLID)) # set x, y, w, h for rectangle self.dc.DrawRectangle(0,0,500, 500) self.dc.EndDrawing() del self.dc def SetNext(self, next): self.next = next def SetPrev(self, prev): self.prev = prev def GetNext(self): return self.next def GetPrev(self): return self.prev def Activated(self, evt): """ Executed when page is being activated. """ return def Blocked(self, evt): """ Executed when page is about to be switched. Switching can be blocked by returning True. """ return False def Cancel(self, evt): """ Executed when wizard is about to be canceled. Canceling can be blocked by returning False. """ return True Thanks guys.

    Read the article

  • Scraping paginated items from a website using scrapy

    - by Mridang Agarwalla
    I'm using scrapy to scrape items from a site. I'm not being able to implement this scraping pattern. The site I'm trying to scrape is a forum and I scrape the site once a day. Each page has a table containing posts. New posts are added to the top of the table and as more and more posts are posted to the site, the older posts go further into the pages due to pagination. This is a very simple scenario and we will assume that the order of the posts never change. I would like to scrape this site and scrape all the "new" records until the last scraped post from yesterday is encountered. I have configured my spider to paginate endlessly and when it encounters yesterday's last scraped post, it should stop. How can implement this? (My Scrapy installation works with my Django installation using django-dynamic-scraper )

    Read the article

  • Load JSON in Python as header character set

    - by mridang
    Hi everyone, I've always found character sets and encodings complicated to understand and here I'm faced with another problem. My apologies for any inaccuracies. I'll do my best. I'm requesting data from a server which returns JSON. In the HTTP headers it also returns the character set like so: Content-Type: text/html; charset=UTF-8 I'm using the JSON library in Python to load the JSON using the json.loads method. When I pass it the returned JSON, it gives me a dictionary in Unicode. I've Googled around and I know that JSON should return Unicode as JavaScript strings are Unicode objects. How can I load the JSON as UTF-8? I would like to use the same encoding as specified in the response header. I've read this post but it didn't help. Thank you.

    Read the article

  • Storing cookielib cookies in a database

    - by Mridang Agarwalla
    Hi, I'm using the cookielib module to handle HTTP cookies when using the urllib2 module in Python 2.6 in a way similar to this snippet: import cookielib, urllib2 cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) r = opener.open("http://example.com/") I'd like to store the cookies in a database. I don't know whats better - serialize the CookieJar object and store it or extract the cookies from the CookieJar and store that. I don't know which one's better or how to implement either of them. I should be also be able to recreate the CookieJar object. Could someone help me out with the above? Thanks in advance.

    Read the article

  • Load JSON in Python as header chracterset

    - by mridang
    Hi everyone, I've always found character-sets and encodings complicated to understand and here I'm faced with another problem. My apologies for any inaccuracies. I'll do my best. I'm requesting data from a server which returns JSON. In the HTTP headers it also returns the character.set like so: Content-Type: text/html; charset=UTF-8 I'm using the JSON library in python to load the JSON using the json.loads method. When I pass it the returned JSON, it gives me a dictionary in Unicode. I've Googled around and I know that JSON should return Unicode as JavaScript strings are Unicode objects. How can I load the JSON as UTF-8. I would like to use the same encoding as specified in the response header. I've read this post but it didn't help. Thank you.

    Read the article

  • Raising events and object persistence in Django

    - by Mridang Agarwalla
    Hi, I have a tricky Django problem which didn't occur to me when I was developing it. My Django application allows a user to sign up and store his login credentials for a sites. The Django application basically allows the user to search this other site (by scraping content off it) and returns the result to the user. For each query, it does a couple of queries of the other site. This seemed to work fine but sometimes, the other site slaps me with a CAPTCHA. I've written the code to get the CAPTCHA image and I need to return this to the user so he can type it in but I don't know how. My search request (the query, the username and the password) in my Django application gets passed to a view which in turn calls the backend that does the scraping/search. When a CAPTCHA is detected, I'd like to raise a client side event or something on those lines and display the CAPTCHA to the user and wait for the user's input so that I can resume my search. I would somehow need to persist my backend object between calls. I've tried pickling it but it doesn't work because I get the Can't pickle 'lock' object error. I don't know to implement this though. Any help/ideas? Thanks a ton.

    Read the article

  • Bulding an multi-platform SWT application using Ant

    - by Mridang Agarwalla
    I'm writing an SWT application which can be used on Windows (32/64 bit) and Mac OSX (32/64 bit). Apart from the JRE I rely on the SWT library found here. I can find four versions of the SWT library depending upon my target platforms (as mentioned above). When building my application, how can I compile using the correct SWT Jar? If possible, I'd like to try and avoid hard-coding the Jar version, platform and architecture. The SWT Jars are named like this: swt-win32-x86_64.jar swt-win32-x86_32.jar swt-macosx-x86_32.jar swt-macosx-x86_64.jar (My project will be an open source project. I'd like people to be able to download the source and build it and therefore I've thought of including all the four versions of the SWT Jars in the source distribution. I hope this is the correct approach of publishing code relying on third-part libraries.) Thanks everyone.

    Read the article

  • Application with both console and gui mode

    - by mridang
    Hi, I have a python console app. Like most python console apps it uses the OptionParser module to take arguments. I've now developed a GUI for my app using wxPython and i'd like to integrate the two. I'd like my app to be run both from the console and from the OS's UI. When it is invoked from the console it runs as a console app and when it is double clicked in the OS's UI, it runs as a GUI app. How could I do something like this? Could someone show me a a snippet of what the __main__ block should be like? Thanks a ton.

    Read the article

  • List all form related errors in django

    - by Mridang Agarwalla
    Hi, Is there a direct way of listing out 'all' form errors in Django templates. I'd like to list out both field and non-field errors and any other form errors. I've found out how to do this on a per-field basis but as said earlier, I'd like to list out everything. The method I'm using doesn't seem to list out everything. {% for error in form.errors %} {{ error|escape }} {% endfor %} Thanks.

    Read the article

  • Shuttle control in wxPython

    - by Mridang Agarwalla
    Hi, I'm trying to implement a shuttle control in wxPython but there doesn't seem to be one. I've decided to use two listbox controls. The shuttle control looks like this: I've got two listboxes — one's populated, one's not. Could someone show me how to add a selected item to the second list box when it is double clicked? It should be removed from the first. When it is double clicked in the second, it should be added to the first and removed from the second. The shuttle control implements these by default but it's a pity it isn't there. Thank you.

    Read the article

  • Pass logger instance to class

    - by mridang
    Hi Guys, I'm using a open-source Python library in my project. This library logs a lot of information using the logging class. ...but I can't see the output or log it to file. I know that i would have to create a logger instance and add a file-handler or a console-handler to it but how can i pass this logger instance to the class? Here's the init snippet of the class that I'm going to be using. class Periscope: ''' Main Periscope class''' def __init__(self): self.config = ConfigParser.SafeConfigParser({"lang": "en"}) if is_local: self.config_file = os.path.join(bd.xdg_config_home, "periscope", "config") if not os.path.exists(self.config_file): folder = os.path.dirname(self.config_file) if not os.path.exists(folder): logging.info("Creating folder %s" %folder) os.mkdir(folder) logging.info("Creating config file") configfile = open(self.config_file, "w") self.config.write(configfile) configfile.close() else: #Load it self.config.read(self.config_file) self.pluginNames = self.listExistingPlugins() self._preferedLanguages = None Any help? Thanks guys.

    Read the article

  • How to return a value when destroying/cleaning-up an object instance

    - by Mridang Agarwalla
    When I initiate a class in Python, I give it some values. I then call method in the class which does something. Here's a snippet: class TestClass(): def __init__(self): self.counter = 0 def doSomething(self): self.counter = self.counter + 1 print 'Hiya' if __name__ == "__main__": obj = TestClass() obj.doSomething() obj.doSomething() obj.doSomething() print obj.counter As you can see, everytime I call the doSomething method, it prints some text and increments an internal variable i.e. counter. When I initiate the class, i set the counter variable to 0. When I destroy the object, I'd like to return the internal counter variable. What would be a good way of doing this? I wanted to know if there were other ways apart from doing stuff like: accessing the variable directly. Like obj.counter. creating a method like getCounter. Thanks.

    Read the article

  • How to fetch parameters when using the Apache Commons CLI library

    - by Mridang Agarwalla
    I'm using the Apache Commons CLI to handle command line arguments in Java. I've figured out my way around it to a decent extent but I need a little help. I've declared the a and b options and I'm able to access the value using CommandLine.getOptionValue. Usage: myapp [OPTION] [DIRECTORY] Options: -a Option A -b Option B How do I declare and access the DIRECTORY variable? Thank you.

    Read the article

< Previous Page | 1 2