-
Notifications
You must be signed in to change notification settings - Fork 473
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
break gam.py into smaller files #147
Comments
360kb. That's nothing, my full blown version with Contacts, serious error handling, etc, is about 820kb. It seems to me that one way to break it up is as follows: Shared stuff: init, globals, utilities, API interface, parsing. I'll experiment with my version to get the feel of it. RossOn Dec 23, 2015, at 5:23 AM, Jay Lee notifications@github.com wrote:
|
@taers232c if we could get gam.py split out it'd make PRs easier and less likely to conflict on merge. For example, if you were doing OAuth changes and they were stored in oauth.py while I'm making changes to Classroom Guardian code stored in classroom_commands.py there would be no conflict (in most cases). Not to mention, it'd make finding code much easier than searching through gam.py :-) I took an initial stab at it but it's messier than I'd hoped. Feel free to take a shot if you'd like though. |
It'd also make things like #23 MUCH easier to work with. I'd love to be of help if I can. I might just have to fork this and see what type of damage I can do and report back with a PR and spark some discussion on the matter. I'd love to know any formatting or ideas you guys have (you know, being the owners and contributors and all), so that I can help contribute to the project upstream. |
Corbin, This will not be easy, it is way beyond a PR, it's a rewrite. I'll look at I have changed by advanced version to be pseudo-importable: #!/usr/bin/env python import os, sys, shlex from gam import ProcessGAMCommand Set appropriate valuesos.environ['GAMCFGDIR'] = '/Users/admin/.gam' GAM_STDOUT = '/tmp/gamstdout.out' Choose how to produce args listrc = ProcessGAMCommand(shlex.split('/Users/admin/GAM/gam.py redirect stdout #rc = ProcessGAMCommand(['/Users/admin/GAM/gam.py', 'redirect', 'stdout', GAM_STDOUT,'info', 'user', 'admin'])print 'GAM returned {0}'.format(rc) with open(GAM_STDOUT, 'rU') as f:
Ross On Wed, Nov 2, 2016 at 2:09 PM, Corbin Crutchley notifications@github.com
Ross Scroggs |
Hi! I've been using this tool for a couple of bits of automation and then almost died when I saw the mono-file architecture. (don't get me wrong, I completely understand how it got to this point!) I'd like to help, the main reason is to create a nicer, more pythonic API for people (like myself) wanting to use GAM as a library for their own python scripts. My suggestion would be that My questions are:
|
I can take a stab at starting to break things apart. I generally agree with the logical split that @jay0lee laid out in the OP. I'll start in that direction and you all can feel free to course correct me, as needed, as the PRs come in. I'm not going to commit to a timeline to doing this, but I'll try to start working on it with what free time I have. This is going to take a while, and I will be purposefully taking out bite-size chunks to make the migration easier to understand and avoid breakage. At the same time, I'll try to add docstrings and push towards making the style more PEP8 compliant, along with adding unit tests where possible. I'm going to avoid rewriting the existing logic as much as possible on this read through, but it will probably necessary in order to untangle some things. (PS: To anyone who sees this comment in 3+ years when this isn't finished, I'm sorry!) |
Start with one of the deepest parts of the stack, Google API request execution calls and associated errors. Critical information printing functions and application control logic are also broken out into their own components. This change also adds unit tests for migrated content and makes code more PEP8 compliant. This commit starts work on GAM-team#147
* Begin breaking apart gam.py into logical pieces Start with one of the deepest parts of the stack, Google API request execution calls and associated errors. Critical information printing functions and application control logic are also broken out into their own components. This change also adds unit tests for migrated content and makes code more PEP8 compliant. This commit starts work on #147 * Add unit tests to Travis config * Swap assert_called_once() with assertEqual() and Mock.call_count Makes tests compatible with Python 3.5. assert_called_once() is only available in Python 3.6+
Continues work on GAM-team#147
Continues work on GAM-team#147
Continues work on GAM-team#147
Continues work on GAM-team#147
* Move callGAPIItems and add unit tests * Move the page-related call() methods and add tests Continues work on #147 * Account for rand addition that rounds to 1.0 In this case, sleep time could be equal to 61
I just pushed: which is an attempt to start breaking the actual GAM command functions into their own file. I expect that this will roughly equate to one file per-API though there are some APIs like Directory where we might want to do one API file per object of the API (users, groups, mobiledevices, etc in the Directory API case). I cheated somewhat to get this done, But for now, the main task is to go ahead and pull the rest of the GAM command functions (functions that for all intent purposes correspond 1:1 with a GAM command) into their own API files. Once that's done we can look at what's left of gam.py and figure out where it should go while also figuring out what a bare minimum gam.py will look like. |
gam.py is freakin huge at ~360kb. We should break it down into smaller files. First draft thoughts on breakdown:
@taers232c thoughts?
The text was updated successfully, but these errors were encountered: