News
Home Home Contact us Contact
home News Projects Tests Files Follow manatlan on Twitter Sign in
2009/01/25 22:06

Cowon iAudio D2 flashmap generator

I'm a new happy user of the Cowon iAudio D2 device. I wanted to use the flashmap viewer of Chrieg, because the D2 is a flash lite compliant device too ;-)

So I'd build a little script which is able to convert any images in a "flash folder ready-to-use" on the D2. This is a python script which use PIL Image to generate jpeg tiles according Chrieg's flashmap specs. It generates a folder with the Chrieg's flashmap v2 and the map. Put this folder in your "D2 flash folder", and run its "view.swf".

The script is here : d2flashmap

Btw, now, it's a lot lot easier to generate a "flashmap map" on the linux platform ;-)

Big thanks to Chrieg for his flashmap !

Comments (View) Tags: d2
2009/01/24 14:52

An ubiquity command for french pages blanches

I'd just made an ubiquity command to search persons in the french pages blanches. Hope it will be useful for anybody. You'll need to have Firefox and ubiquity extension to start using it. And sure, you'll need to be french to find it useful ;-)

Comments (View)
2009/01/01 15:53

Jbrout 0.3 is out ... and happy new year

The (really so long awaited) 0.3 release is now available for *nix platforms (the win32 will be released soon). A lot of changes : new official dev web site, a new svn repository. This 0.3 release introduce the use of the exiv2 library with the pyexiv2 python backend, a better way for the future. The, poor and fast-made, announce on the jBrout group

Big thanks to Rob (for helps on jbrout), and Olivier (for his pyexiv2) !

Comments (View) Tags: jbrout
2008/12/06 18:55

New python, new webpy

Great ! Yesterday, the famous python 3000 was released. And today it's the so long awaited 0.3 release of webpy which was released. It's marvelous ...

Comments (View)
2008/12/05 07:36

Sandy gives up

I'm sad. Sandy was a great web service, and really useful for me. She lets me plan my events easily, by sending mails to her. The 12/8 (in three days): she will give up definitively. She will work at twitter ;-(. Til today, there is no alternative. It's a shame.

The good news : I started to build my own. But I don't know yet if I will let my service available for everyone. It works (for me), and it's a little bit different. First, I use the great smtp2web.com, which let me post a mail to an url. The content of the mail is analyzed by my own module (french only), and events are added to my own google calendar, with an email reminder (with the gcalendar quick add feature). The down side is that the reminder is sent by google, and I couldn't tell him to cancel or snooze the event ;-(. The good side is that I can manage events easily in my google calendar. In fact, it's just a google calendar front end, hosted on GAE. It was easier to do. I had planned my first real event this morning, and it seems to work ;-). I need to find a way to simulate todo tasks (recurrent events ?), and a way to cancel/snooze events by mails (by forwarding them ?!).

Edit 2008/12/06 : I've got my sandy back. It works very well with snooze function too (by forwarding the mail). And all in french, with real timezone. I always don't know yet if I will let others sign in (perhaps a private beta) ...

The big drawback : does people want I have full access to their google calendar ? (but you could revoke grant access at any time from a google console)

Btw, now, my own test module(which I should upgrade/correct) use wobpy too.

Comments (View)
2008/11/26 22:44

AppJet is marvelous

Since 2 days, I play with AppJet. It's a fabulous web platform. It lets you code a webapp (and not a toy), in a kind of IDE in the browser. It's really interesting how all is working well. In a simple browser, you can start to code your web app. You can see, in live, the result. You can use a "lot of" libraries (persistant storage, http get, facebook and some nice tricks). And they are well documented !

The language is a sort of SSJS (Server Side JavaScript), so it's easy to code client side or server side without switching. AppJet let you host your app in their servers, with a 50MB free storage (with domain name too). Or you can run your own, with an appjet java1.6 runtime which is downloadable. Sources of all hosted apps are available, and clonable. Really useful to find some helps/tricks.

Another incredible thing it that guide to learn to program, which is intended for masses. You can interact, in live, with little examples. Really nifty !

I like a lot, and find it very useful to test some things, or to setup quickly a pipe, a tool, ... in a simple browser. It's really amazing how it's so simple and so powerful too.

Comments (View)
2008/11/23 23:08

Wobpy in live, on facebook

To try Wobpy, I've made a little facebook app called Bastons which uses it a lot. It works. The app is hosted on GAE with the pyfacebook api. Really amazing. GAE is definitively a great platform for facebook app too. Wobpy works well, but I need to find a better way to communicate between webpy (and others python web frameworks) and wobpy ; it's not very natural.

Comments (View) Tags: wobpy, gae
2008/11/11 22:20

Introducing wobpy

Forget my last post. Since that day, I'm working on another concept, which is a lot more interesting. It uses webpy and jQuery too. I've found a way to make some kind of server components. So it will be easy to code a web form like we code a gtk window : instantiate a widget, add some objects (textarea, button, checkbox ...), declare theirs events ... and code in python only (no html, no javascript, no ajax call).

It's fully ajax, and coders shouldn't write any line of javascript. All states and events are transfered during the ajax call, silently. On the server side, objects keep in sync with the client.

Yes, it's yet another kind of GUI on the web, but it's amazing for me ;-). It's based on webpy, and should be an external lib. So I named it : wobpy (like webpy), wob for "web object".

here is an example :

class MyForm(Wobpy):
    def __init__(self):
        Wobpy.__init__(self)

        self.t = TextArea()
        self.add(self.t)

        b=Button("go")
        b.connect("onclick",self.onbclick)
        self.add(b)

        self.l = Label()
        self.add(self.l)

    def onbclick(self):
        v=self.t.get_value()
        self.l.set_text( v )

When instantiate in a webpy mapped class, it will display a textarea, where you can enter some text, and when you click on the button 'go', it will put the entered text in a label.

Note that it looks like a gtk.Window, and could be easily mapped to gtk. It's really amazing.

It will be there when it'll ready for prime time.

Comments (View) Tags: wobpy
2008/11/08 14:26

Near the perfect ajax method #1

It's not my first try. I like to find the ultimate way to do this kind of thing. In this approach, I really needed a way to send multiple needs, and to retrieve many results. It's based on jQuery (clientside) and webpy (serverside) (with a json lib like demjson), as always. It's a proof of concept, but it feeds my needs (and perhaps yours)

On the client side, it's a classical ajax method :

function ajax( method, data, callback ) {...}

method define the server side method, data is a classical dict, and callback is a optional callback.

A simple example, on client side, could be :

<button onclick='ajax( "method1", {arg1:"hello"} );'>test</button>

On server side :

@Ajax.entry
def method1(arg1="bonjour"):
    return {"result":arg1*2}

Which does nothing, except returning a object which have got an attribut result which contains 'hellohello'. But the previous client side call don't care about the result. To use the result on the client side, we should use something like this :

<button onclick='ajax( "method1", {arg1:"hello"}, function(o) {alert(o.result);} );'>test</button>

Which should display 'hellohello' in an alert box.

Note, as on the server side, the python method method1 has got a default value for param arg1. It could be possible to call the ajax method without providing a arg1 :

<button onclick='ajax( "method1", {}, function(o) {alert(o.result);} );'>test</button>

Which should display 'bonjourbonjour' in an alert box.

Until here, it's a very classical ajax method : A call, and a return as a dict. A neat feature is that you can fill html tags on server side. On this simple example, client side :

<button onclick='ajax( "method2" );'>test</button>
<div id="out1"></result>
<div id="out2"></result>

server side :

@Ajax.entry
def method2():
    return {"[#out1]":"hello1","[#out2]":"hello2"}

The div#out1 and div#out2 will be automatically filled with the response of the server method. It use the "[]" trick to encapsulate a jquery selector. It's just a simple way, to feed some tag on the clientside. Another neat feature is that you can send back a javascript call in your response, by adding a key script in your result like this :

@Ajax.entry
def method2():
    return {"[#out1]":"hello1","[#out2]":"hello2","script":"alert(1)"}

which should feed div#out1 and div#out2, and display an alert box containing '1'. So it's easy to define javascript calls, or feed a client tag, by doing it on the serverside, in a python way.

But the great feature, is that you can call many methods from the server side in one client ajax call, by passing a list of methods, like this :

<button onclick='ajax( ["method1","method2"], {arg1:'ciao'});'>test</button>

method1 will be executed at first, and method2 at last. Each method will try to find its own parameters in the dict. Thus, parameters can be shared between methods.

And better : method1 could set parameters for method2 like this:

@Ajax.entry
def method1(arg1):
    return {"arg2":arg1*2}

@Ajax.entry
def method2(arg2):
    return {"[#out]":arg2*2}

arg2 is populated by method1, thus method2 can use it (although it was not defined at the ajax call). It should set 'ciaociaociaociao' in a div#out.

Here is the webpy(v0.3) code :

URLS = (
    '/',"Ajax",
    '/ajax',"Ajax",
)

import inspect
import demjson

class Ajax:
    """
        function ajax(methods,dico,callback)
        {
            if(!dico) dico={};
            dico["_methods_"] = methods;

            $.post("/ajax", dico,
                function(data){
                    var obj = eval("("+data+")");
                    if(obj._err_)
                        alert(obj._err_);
                    else {
                        if(obj._contents_) {
                            for(var idx in obj._contents_) {
                                var c_c=obj._contents_[idx];
                                $(c_c[0]).html(c_c[1]);
                            }
                        }

                        if(obj._scripts_) {
                            for(var idx in obj._scripts_)
                                eval(obj._scripts_[idx]);
                        }

                        if(callback)
                            callback(obj)
                    }
                }
            );
        }
    """
    class _MethodDict_(dict):
      def __call__(self, func):
        self[func.__name__] = func
    entry = _MethodDict_()  #decorator


    def POST(self):
        def log(a):
            print str(a)
        def ResultSet(dico):
            return demjson.encode(dico)
        def error(m):
            log("--> "+err)
            return ResultSet({"_err_":str(m)})

        data=web.input(_methods_=[])
        methods = data["_methods_"]
        del data["_methods_"]

        result = {}
        for method in methods:
            if method in Ajax.entry:
                fct=Ajax.entry[method]
            else:
                return error("Method '%s' doesn't exist"%(method,))
            fct_args=inspect.getargspec(fct)[0]
            args={}
            for a in fct_args:
                if a in data: # else, hope there is a default value in method def
                    args[a] = data[a]   #fill args for method
            log("ajax call "+method+"("+str(args)+")")
            try:
                rs = fct(**args)
                log("--> "+str(rs))
                if rs:
                    if type(rs)!=dict:
                        return error("Method '%s' don't return a dict"%(method,))
                    else:
                        for k in rs.keys():
                            if k[0]=="[" and k[-1]=="]":
                                result.setdefault("_contents_",[]).append( [k[1:-1],rs[k]] )
                                del rs[k]

                        if "script" in rs:
                            result.setdefault("_scripts_",[]).append(rs["script"])
                            del rs["script"]

                        result.update( rs )
                        data.update( rs )
            except Exception,m:
                err="Error in '%s' : %s : %s"%(method,Exception,m)
                return error(err)

        log("Return:"+str(result))
        return ResultSet(result)

    def GET(self):
        web.header("content-type","text/html")
        return """
        <html>
        <head>
            <script type="text/javascript" src="/static/jquery.js"></script>
            <script type="text/javascript">%s</script>
        </head>
        <body>
            <button onclick='ajax( "jack", {arg2:"hello1"} );'>go1</button>
            <button onclick='ajax( "jo", {arg1:"hello2"} );'>go2</button>
            <button onclick='ajax( "jo" );'>go3</button>
            <button onclick='ajax( ["jo","jack"], {} );'>go4</button>
            <button onclick='ajax( ["jo","jack"], {arg1:"hello5"} );'>go5</button>
            <div id="result"></div>
        </body>
        </html>
        """ % Ajax.__doc__


@Ajax.entry
def jo(arg1="koko"):
    return {"arg2":arg1,"script":"$('#result').css('border','1px solid red')"}

@Ajax.entry
def jack(arg2):
    return {"[#result]":arg2*2}

Comments (View)
2008/10/17 07:15

Did I told you that I loved python and GAE ?

I can't remember. But it's true. With the exception of the recents problems, GAE which give up hosting of naked domains, and this bug in webpy : this website was nearly unreachable. It takes me some days to find them, but it's always a real pleasure to hack python and GAE hosting. It's really easy and pleasant.

This website is now fully functional. I've started to migrate pages from my old websites to here, and this one will really be my main one. All tools (wiki, blog, files, tagging, comments from disqus) were really simple to implement and to maintain. Thanks to webpy too, in its 0.3 version (which is not fully compatible with GAE currently), this (anti-)framework fits well with GAE.

And more : it's friday ... I love friday too ;-)

Comments (View) Tags: gae
<< oldest newest >>

Tags

RSS Python Powered Get Ubuntu
©opyleft 2008-2019 - manatlan