-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #680 from OpenC3/bucket_load
Bucket load
- Loading branch information
Showing
3 changed files
with
92 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# encoding: ascii-8bit | ||
|
||
# Copyright 2022 OpenC3, Inc. | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can modify and/or redistribute it | ||
# under the terms of the GNU Affero General Public License | ||
# as published by the Free Software Foundation; version 3 with | ||
# attribution addendums as found in the LICENSE.txt | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# This file may also be used under the terms of a commercial license | ||
# if purchased from OpenC3, Inc. | ||
|
||
require 'openc3' | ||
require 'openc3/utilities/bucket_utilities' | ||
|
||
OpenC3.disable_warnings do | ||
def require(*args, **kw_args) | ||
begin | ||
return super(*args, **kw_args) | ||
rescue LoadError | ||
begin | ||
@bucket_require_cache ||= {} | ||
if @bucket_require_cache[args[0]] | ||
return false | ||
else | ||
scope = nil | ||
if kw_args[:scope] | ||
scope = kw_args[:scope] | ||
else | ||
scope = $openc3_scope | ||
end | ||
OpenC3::BucketUtilities.bucket_load(*args, scope: scope) | ||
@bucket_require_cache[args[0]] = true | ||
return true | ||
end | ||
rescue Exception => err | ||
raise LoadError, "#{err.class}:#{err.message}", err.backtrace | ||
end | ||
end | ||
end | ||
|
||
def load(*args, **kw_args) | ||
begin | ||
super(*args, **kw_args) | ||
rescue LoadError | ||
begin | ||
scope = nil | ||
if kw_args[:scope] | ||
scope = kw_args[:scope] | ||
else | ||
scope = $openc3_scope | ||
end | ||
OpenC3::BucketUtilities.bucket_load(*args, scope: scope) | ||
rescue Exception | ||
raise LoadError, "#{err.class}:#{err.message}", err.backtrace | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters