Dropbox backend: global name 'rest' is not defined when changing app id and secret

Asked by Cyrus David

Steps I did:

1. `curl -L http://code.launchpad.net/duplicity/0.6-series/0.6.24/+download/duplicity-0.6.24.tar.gz | tar xz`
2. `cd duplicity-0.6.24`
3. `vim duplicity/backends/dpbxbackend.py` and change the `APP_KEY` and `APP_SECRET` values.
4. `sudo checkinstall python setup.py install`

The error:

```
Traceback (most recent call last):
  File "/usr/local/bin/duplicity", line 1502, in <module>
    with_tempdir(main)
  File "/usr/local/bin/duplicity", line 1496, in with_tempdir
    fn()
  File "/usr/local/bin/duplicity", line 1329, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/duplicity/commandline.py", line 1059, in ProcessCommandLine
    backup, local_pathname = set_backend(args[0], args[1])
  File "/usr/local/lib/python2.7/dist-packages/duplicity/commandline.py", line 952, in set_backend
    globals.backend = backend.get_backend(bend)
  File "/usr/local/lib/python2.7/dist-packages/duplicity/backend.py", line 163, in get_backend
    return _backends[pu.scheme](pu)
  File "/usr/local/lib/python2.7/dist-packages/duplicity/backends/dpbxbackend.py", line 156, in __init__
    self.login()
  File "/usr/local/lib/python2.7/dist-packages/duplicity/backends/dpbxbackend.py", line 162, in login
    except rest.ErrorResponse, e:
NameError: global name 'rest' is not defined
```

Question information

Language:
English Edit question
Status:
Solved
For:
Duplicity Edit question
Assignee:
No assignee Edit question
Solved by:
edso
Solved:
Last query:
Last reply:
Revision history for this message
Best edso (ed.so) said :
#1

On 15.10.2014 04:26, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Description changed to:
> Steps I did:
>
> 1. `curl -L http://code.launchpad.net/duplicity/0.6-series/0.6.24/+download/duplicity-0.6.24.tar.gz | tar xz`
> 2. `cd duplicity-0.6.24`
> 3. `vim duplicity/backends/dpbxbackend.py` and change the `APP_KEY` and `APP_SECRET` values.
> 4. `sudo checkinstall python setup.py install`
>
> The error:
>
> ```
> Traceback (most recent call last):
> File "/usr/local/bin/duplicity", line 1502, in <module>
> with_tempdir(main)
> File "/usr/local/bin/duplicity", line 1496, in with_tempdir
> fn()
> File "/usr/local/bin/duplicity", line 1329, in main
> action = commandline.ProcessCommandLine(sys.argv[1:])
> File "/usr/local/lib/python2.7/dist-packages/duplicity/commandline.py", line 1059, in ProcessCommandLine
> backup, local_pathname = set_backend(args[0], args[1])
> File "/usr/local/lib/python2.7/dist-packages/duplicity/commandline.py", line 952, in set_backend
> globals.backend = backend.get_backend(bend)
> File "/usr/local/lib/python2.7/dist-packages/duplicity/backend.py", line 163, in get_backend
> return _backends[pu.scheme](pu)
> File "/usr/local/lib/python2.7/dist-packages/duplicity/backends/dpbxbackend.py", line 156, in __init__
> self.login()
> File "/usr/local/lib/python2.7/dist-packages/duplicity/backends/dpbxbackend.py", line 162, in login
> except rest.ErrorResponse, e:
> NameError: global name 'rest' is not defined
> ```
>

can you try to add the following line

 global client, rest, session

as line 103 into

 /usr/local/lib/python2.7/dist-packages/duplicity/backends/dpbxbackend.py"

?

it should then look like

...
    def __init__(self, parsed_url):
        duplicity.backend.Backend.__init__(self, parsed_url)

        global client, rest, session
        from dropbox import client, rest, session
...

does that work?.. ede/duply.net

Revision history for this message
Cyrus David (apathetic012) said :
#2

@edso yes, it does! Thank you. Now it successfully shows the error:

dpbx error: [403] u"Invalid app key (consumer key). Check your app's configuration to make sure everything is correct."

I checked the app key, secret and they are correct.

Revision history for this message
edso (ed.so) said :
#3

On 15.10.2014 11:56, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Cyrus David posted a new comment:
> @edso yes, it does! Thank you. Now it successfully shows the error:
>
> dpbx error: [403] u"Invalid app key (consumer key). Check your app's
> configuration to make sure everything is correct."
>
> I checked the app key, secret and they are correct.
>

what's wrong with the developer key already in the backend? ..ede

Revision history for this message
Cyrus David (apathetic012) said :
#4

I removed the lines calling the function etacsufbo() and it worked. Is that function something that's specifically just for the default key and secret?

Revision history for this message
Cyrus David (apathetic012) said :
#5

Thanks edso, that solved my question.

Revision history for this message
edso (ed.so) said :
#6

On 15.10.2014 12:07, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Cyrus David posted a new comment:
> I removed the lines calling the function etacsufbo() and it worked. Is
> that function something that's specifically just for the default key and
> secret?
>

dunno.. i am not author. the backend comment says

# This application key is registered in my name (jno at pisem dot net).
# You can register your own developer account with Dropbox and
# register a new application for yourself, obtaining the new
# APP_KEY and APP_SECRET.
# Note 1: you must not store your credentials "as is" in the code.
# The values must be "processed" at least.
# This is a must for "production" keys.
# Note 2: the name of the application defines the name of the
# subfolder in the "Apps" folder.
# http://www.dropbox.com/developers/apps is the place to get the key.

are your values _processed_ ? ..ede

Revision history for this message
edso (ed.so) said :
#7

On 15.10.2014 12:07, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Cyrus David posted a new comment:
> I removed the lines calling the function etacsufbo() and it worked. Is
> that function something that's specifically just for the default key and
> secret?
>

why don't you try to contact the backends author?
 jno at pisem dot net

;).. ede

Revision history for this message
edso (ed.so) said :
#8

On 15.10.2014 12:12, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Status: Answered => Solved
>
> Cyrus David confirmed that the question is solved:
> Thanks edso, that solved my question.
>

what exactly.. processing or the author's address? ..ede/diply.net

Revision history for this message
Cyrus David (apathetic012) said :
#9

> what's wrong with the developer key already in the backend? ..ede

I wanted to put the files at the root. Instead of `Apps/duplicity`.

> what exactly.. processing or the author's address? ..ede/diply.net

I just removed the etacsufbo() function calls haha, they're to be used on my servers anyway so I don't see the point of doing that.

Thank you so much for helping me!

Revision history for this message
edso (ed.so) said :
#10

On 15.10.2014 12:52, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Cyrus David posted a new comment:
>> what's wrong with the developer key already in the backend? ..ede
>
> I wanted to put the files at the root. Instead of `Apps/duplicity`.
>
>> what exactly.. processing or the author's address? ..ede/diply.net
>
> I just removed the etacsufbo() function calls haha, they're to be used
> on my servers anyway so I don't see the point of doing that.

just figured out that etacsufbo() is inverted for obfuscate().. which is neither secure not anything as the backend delivers the deobfuscation code.

> Thank you so much for helping me!
>

welcome.. have to upload a branch for the fix still.. ede/duply.net

Revision history for this message
Cyrus David (apathetic012) said :
#11

I could have easily submitted a pull request if this was hosted on github :P

Revision history for this message
edso (ed.so) said :
#12

On 15.10.2014 16:26, Cyrus David wrote:
> Question #255740 on Duplicity changed:
> https://answers.launchpad.net/duplicity/+question/255740
>
> Cyrus David posted a new comment:
> I could have easily submitted a pull request if this was hosted on
> github :P
>

well it ain't.. and probably won't be as the maintainer and the other main contributor are ubuntu users/fans for some reason ;)

..ede

Revision history for this message
Kenneth Loafman (kenneth-loafman) said :
#13

Actually, I'm a big fan of git, but hate moving. Catch-22!

On Wed, Oct 15, 2014 at 9:28 AM, <email address hidden> wrote:

> On 15.10.2014 16:26, Cyrus David wrote:
> > Question #255740 on Duplicity changed:
> > https://answers.launchpad.net/duplicity/+question/255740
> >
> > Cyrus David posted a new comment:
> > I could have easily submitted a pull request if this was hosted on
> > github :P
> >
>
> well it ain't.. and probably won't be as the maintainer and the other main
> contributor are ubuntu users/fans for some reason ;)
>
> ..ede
>

Revision history for this message
Michael Terry (mterry) said :
#14

:) It's not about Ubuntu, I believe we were hosted on Savannah before?
And their UI was/is awful. LP at the time was putting effort into being a
nice project host. They've seemed to have stopped working so much on that
though.

On 15 October 2014 10:28, <email address hidden> wrote:

> On 15.10.2014 16:26, Cyrus David wrote:
> > Question #255740 on Duplicity changed:
> > https://answers.launchpad.net/duplicity/+question/255740
> >
> > Cyrus David posted a new comment:
> > I could have easily submitted a pull request if this was hosted on
> > github :P
> >
>
> well it ain't.. and probably won't be as the maintainer and the other main
> contributor are ubuntu users/fans for some reason ;)
>
> ..ede
>