kevin1024 / fabric_remote

REST API for Fabric
25 stars 5 forks source link

fabric function is not JSON serializable #7

Closed cruisemaniac closed 10 years ago

cruisemaniac commented 10 years ago

I have this in my fabfile.py:

def listfiles():
    run('ls -al')
    run('ls -al')
    run('ls -al')
    run('ls -al')
    run('ls -al')
    run('ls -al')
    run('ls -al')
    run('ls -al')
    run('ls -al')

Upon hitting the /tasks route, this is the error I get:

TypeError: <function listfiles at 0x0000000003BA4048> is not JSON serializable
...
...
    File "C:\Python27\Lib\json\encoder.py", line 270, in iterencode

    return _iterencode(o, 0)

    File "build\bdist.win-amd64\egg\fabric_remote\tasks.py", line 105, in default

    return json.JSONEncoder.default(self, obj)

    File "C:\Python27\Lib\json\encoder.py", line 184, in default

    raise TypeError(repr(o) + " is not JSON serializable")

    TypeError: <function listfiles at 0x0000000003BA4048> is not JSON serializable
cruisemaniac commented 10 years ago

Okay,

This does not seem to be an issue per se but I have a very hard time trying to figure out how the file is laid out - line endings et al... or the not JSON serializable thing pops up!

I guess, this can be closed!

kevin1024 commented 10 years ago

I agree this is pretty weird. This is what happens when you do not use the @task decorator in your fabfile. I need a friendlier message to deal with this.

kevin1024 commented 10 years ago

How did you find fabric remote? Out of curiosity.

cruisemaniac commented 10 years ago

Absolutely awesome!!! I'm a n00b python programmer stuck in a position where I need to automate a sh*t ton of things... Fabric was the only tool that made sense!

I wanted to get the web way of doing this and it looks like fabric_remote is an awesome tool!

You have a new fan! :-D