Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Missing module - cannot import name run (revisit #204) #229

Closed
TheDreamer opened this issue Jan 23, 2016 · 2 comments
Closed

ERROR: Missing module - cannot import name run (revisit #204) #229

TheDreamer opened this issue Jan 23, 2016 · 2 comments

Comments

@TheDreamer
Copy link

Since there's no easy way to rollback oauth2client to 1.4.12 on my servers, I made a quick patch to get things running. Followed by some additional corrections to make it actually work.

According the commit to oauth2client, the old_run module was removed as it had been deprecated since July 2, 2013. It used to say in this module:

"""This module holds the old run() function which is deprecated, the
tools.run_flow() function should be used in its place."""

Since v1.3 was Sep 29, 2014, I would guess this to be safe for oauth2client <= 1.4.12 users. Only did a quick test against 1.4.12 (though Ubuntu 14.04 comes with 1.2 which didn't work, don't know why backports has gcalcli 3.3.2, but not updated python modules needed by it. actually it might have been copy/paste error of the authorization...)

When I first ran it, I got:

WARNING:root:This function, oauth2client.tools.run(), and the use of the gflags library are deprecated and will be removed in a future version of the library.
Go to the following link in your browser:

But, here's the quick patch I did to get it working against oath2client v1.5.2 (and tested against 1.4.12)

--- gcalcli.orig    2014-12-17 01:50:24 UTC
+++ gcalcli
@@ -185,7 +185,8 @@ try:
     from apiclient.discovery import build
     from oauth2client.file import Storage
     from oauth2client.client import OAuth2WebServerFlow
-    from oauth2client.tools import run
+    from oauth2client.tools import run_flow
+    from oauth2client.tools import argparser
 except ImportError as e:
     print "ERROR: Missing module - %s" % e.args[0]
     sys.exit(1)
@@ -627,14 +628,15 @@ class gcalcli:
             credentials = storage.get()

             if credentials is None or credentials.invalid:
-                credentials = run(
+       args, unknown = argparser.parse_known_args(sys.argv)
+                credentials = run_flow(
                     OAuth2WebServerFlow(
                         client_id=self.client_id,
                         client_secret=self.client_secret,
                         scope=['https://www.googleapis.com/auth/calendar',
                                'https://www.googleapis.com/auth/urlshortener'],
                         user_agent=__program__+'/'+__version__),
-                    storage)
+                    storage, args)

             self.authHttp = credentials.authorize(httplib2.Http())

@tresni
Copy link
Collaborator

tresni commented Jan 23, 2016

Duplicate of #211 . The argpase_over_gflags branch is the eventual answer, I just need to spend sometime to finish it.

@tresni tresni closed this as completed Jan 23, 2016
@TheDreamer
Copy link
Author

This is not totally a duplicate of #211, as I had initially submitted the same workaround for FreeBSD to later discover that it doesn't work for new authentication.

Hence the additional switch to using run_flow (which takes 3 args, not just 2 that run() did.) and calling argparser.parse_known_args() to get the args that run_flow wanted and ignore the rest.

This patch came in handy when I later did a new setup on a headless server and needed to use ‑‑noauth_local_webserver.

Eventually a full switch to using argparse (and parenting argparser)? over gflags would be best...but, I'm already out of my depth....

uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 30, 2016
gcalcli requires a dependency on oauth2client <= 1.4.12 to work
correctly, as higher versions replaced the run() method with run_flow().

The version of oauth2client in ports is 2.2.0 at the time of writing.

Fixes for the issue [1][2][3] have been submitted upstream in multiple
cases, although upstream has closed them as duplicates of a refactor
issue [4] that is yet to be committed/resolved.

This commit commits the proposed change in issue #229 [2].

While I'm here:

* Explicitly specify (and limit) supported Python versions to -2.x
* Add python to CATEGORIES
* Group, re-order and sort USE{s}, NO_* and files/plist sections
* Capitalize OPTIONS descriptions

[1] insanum/gcalcli#211
[2] insanum/gcalcli#229
[3] insanum/gcalcli#244
[4] insanum/gcalcli#165

PR:		206045
Submitted by:	Lawrence Chen <beastie tardisi com>
Approved by:	portmgr (maintainer timeout, 6+ months)
MFH:		2016Q3


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@419306 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 30, 2016
gcalcli requires a dependency on oauth2client <= 1.4.12 to work
correctly, as higher versions replaced the run() method with run_flow().

The version of oauth2client in ports is 2.2.0 at the time of writing.

Fixes for the issue [1][2][3] have been submitted upstream in multiple
cases, although upstream has closed them as duplicates of a refactor
issue [4] that is yet to be committed/resolved.

This commit commits the proposed change in issue #229 [2].

While I'm here:

* Explicitly specify (and limit) supported Python versions to -2.x
* Add python to CATEGORIES
* Group, re-order and sort USE{s}, NO_* and files/plist sections
* Capitalize OPTIONS descriptions

[1] insanum/gcalcli#211
[2] insanum/gcalcli#229
[3] insanum/gcalcli#244
[4] insanum/gcalcli#165

PR:		206045
Submitted by:	Lawrence Chen <beastie tardisi com>
Approved by:	portmgr (maintainer timeout, 6+ months)
MFH:		2016Q3
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 30, 2016
gcalcli requires a dependency on oauth2client <= 1.4.12 to work
correctly, as higher versions replaced the run() method with run_flow().

The version of oauth2client in ports is 2.2.0 at the time of writing.

Fixes for the issue [1][2][3] have been submitted upstream in multiple
cases, although upstream has closed them as duplicates of a refactor
issue [4] that is yet to be committed/resolved.

This commit commits the proposed change in issue #229 [2].

While I'm here:

* Explicitly specify (and limit) supported Python versions to -2.x
* Add python to CATEGORIES
* Group, re-order and sort USE{s}, NO_* and files/plist sections
* Capitalize OPTIONS descriptions

[1] insanum/gcalcli#211
[2] insanum/gcalcli#229
[3] insanum/gcalcli#244
[4] insanum/gcalcli#165

PR:		206045
Submitted by:	Lawrence Chen <beastie tardisi com>
Approved by:	portmgr (maintainer timeout, 6+ months)

Approved by:	ports-secteam (blanket)
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Dec 2, 2016
gcalcli requires a dependency on oauth2client <= 1.4.12 to work
correctly, as higher versions replaced the run() method with run_flow().

The version of oauth2client in ports is 2.2.0 at the time of writing.

Fixes for the issue [1][2][3] have been submitted upstream in multiple
cases, although upstream has closed them as duplicates of a refactor
issue [4] that is yet to be committed/resolved.

This commit commits the proposed change in issue #229 [2].

While I'm here:

* Explicitly specify (and limit) supported Python versions to -2.x
* Add python to CATEGORIES
* Group, re-order and sort USE{s}, NO_* and files/plist sections
* Capitalize OPTIONS descriptions

[1] insanum/gcalcli#211
[2] insanum/gcalcli#229
[3] insanum/gcalcli#244
[4] insanum/gcalcli#165

PR:		206045
Submitted by:	Lawrence Chen <beastie tardisi com>
Approved by:	portmgr (maintainer timeout, 6+ months)

Approved by:	ports-secteam (blanket)
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Apr 1, 2021
gcalcli requires a dependency on oauth2client <= 1.4.12 to work
correctly, as higher versions replaced the run() method with run_flow().

The version of oauth2client in ports is 2.2.0 at the time of writing.

Fixes for the issue [1][2][3] have been submitted upstream in multiple
cases, although upstream has closed them as duplicates of a refactor
issue [4] that is yet to be committed/resolved.

This commit commits the proposed change in issue #229 [2].

While I'm here:

* Explicitly specify (and limit) supported Python versions to -2.x
* Add python to CATEGORIES
* Group, re-order and sort USE{s}, NO_* and files/plist sections
* Capitalize OPTIONS descriptions

[1] insanum/gcalcli#211
[2] insanum/gcalcli#229
[3] insanum/gcalcli#244
[4] insanum/gcalcli#165

PR:		206045
Submitted by:	Lawrence Chen <beastie tardisi com>
Approved by:	portmgr (maintainer timeout, 6+ months)

Approved by:	ports-secteam (blanket)
svmhdvn pushed a commit to svmhdvn/freebsd-ports that referenced this issue Jan 10, 2024
gcalcli requires a dependency on oauth2client <= 1.4.12 to work
correctly, as higher versions replaced the run() method with run_flow().

The version of oauth2client in ports is 2.2.0 at the time of writing.

Fixes for the issue [1][2][3] have been submitted upstream in multiple
cases, although upstream has closed them as duplicates of a refactor
issue [4] that is yet to be committed/resolved.

This commit commits the proposed change in issue #229 [2].

While I'm here:

* Explicitly specify (and limit) supported Python versions to -2.x
* Add python to CATEGORIES
* Group, re-order and sort USE{s}, NO_* and files/plist sections
* Capitalize OPTIONS descriptions

[1] insanum/gcalcli#211
[2] insanum/gcalcli#229
[3] insanum/gcalcli#244
[4] insanum/gcalcli#165

PR:		206045
Submitted by:	Lawrence Chen <beastie tardisi com>
Approved by:	portmgr (maintainer timeout, 6+ months)
MFH:		2016Q3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants