Skip to content

Commit

Permalink
Update copyright.
Browse files Browse the repository at this point in the history
  • Loading branch information
craig8 committed Nov 8, 2023
1 parent f2f2da0 commit 961a96c
Show file tree
Hide file tree
Showing 394 changed files with 16,890 additions and 22,231 deletions.
116 changes: 51 additions & 65 deletions bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
# -*- coding: utf-8 -*- {{{
# vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et:
# ===----------------------------------------------------------------------===
#
# Copyright 2020, Battelle Memorial Institute.
# Component of Eclipse VOLTTRON
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# ===----------------------------------------------------------------------===
#
# http://www.apache.org/licenses/LICENSE-2.0
# Copyright 2023 Battelle Memorial Institute
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This material was prepared as an account of work sponsored by an agency of
# the United States Government. Neither the United States Government nor the
# United States Department of Energy, nor Battelle, nor any of their
# employees, nor any jurisdiction or organization that has cooperated in the
# development of these materials, makes any warranty, express or
# implied, or assumes any legal liability or responsibility for the accuracy,
# completeness, or usefulness or any information, apparatus, product,
# software, or process disclosed, or represents that its use would not infringe
# privately owned rights. Reference herein to any specific commercial product,
# process, or service by trade name, trademark, manufacturer, or otherwise
# does not necessarily constitute or imply its endorsement, recommendation, or
# favoring by the United States Government or any agency thereof, or
# Battelle Memorial Institute. The views and opinions of authors expressed
# herein do not necessarily state or reflect those of the
# United States Government or any agency thereof.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# PACIFIC NORTHWEST NATIONAL LABORATORY operated by
# BATTELLE for the UNITED STATES DEPARTMENT OF ENERGY
# under Contract DE-AC05-76RL01830
# ===----------------------------------------------------------------------===
# }}}

"""bootstrap - Prepare a VOLTTRON virtual environment.
Expand Down Expand Up @@ -85,9 +71,9 @@
_log = logging.getLogger(__name__)

_WINDOWS = sys.platform.startswith('win')
default_rmq_dir = os.path.join(os.path.expanduser("~"), "rabbitmq_server")
rmq_version = "3.9.29"
rabbitmq_server = f"rabbitmq_server-{rmq_version}"
default_rmq_dir = os.path.join(os.path.expanduser('~'), 'rabbitmq_server')
rmq_version = '3.9.29'
rabbitmq_server = f'rabbitmq_server-{rmq_version}'


def shescape(args):
Expand All @@ -97,15 +83,15 @@ def shescape(args):


def bootstrap(dest, prompt='(volttron)', version=None, verbose=None):
args = [sys.executable, "-m", "venv", dest, "--prompt", prompt]
args = [sys.executable, '-m', 'venv', dest, '--prompt', prompt]

complete = subprocess.run(args, stdout=subprocess.PIPE)
if complete.returncode != 0:
sys.stdout.write(complete.stdout.decode('utf-8'))
shutil.rmtree(dest, ignore_errors=True)
sys.exit(1)

return os.path.join(dest, "bin/python")
return os.path.join(dest, 'bin/python')


def pip(operation, args, verbose=None, offline=False):
Expand All @@ -125,7 +111,7 @@ def pip(operation, args, verbose=None, offline=False):

def update(operation, verbose=None, offline=False, optional_requirements=[], rabbitmq_path=None):
"""Install dependencies in setup.py and requirements.txt."""
print("UPDATE: {}".format(optional_requirements))
print('UPDATE: {}'.format(optional_requirements))
assert operation in ['install', 'wheel']
wheeling = operation == 'wheel'
path = os.path.dirname(__file__) or '.'
Expand Down Expand Up @@ -159,75 +145,75 @@ def update(operation, verbose=None, offline=False, optional_requirements=[], rab
if optional_requirements:
target += '[' + ','.join(optional_requirements) + ']'
args.extend(['--editable', target])
print(f"Target: {target}")
print(f'Target: {target}')
pip(operation, args, verbose, offline)

try:
# Install rmq server if needed
if rabbitmq_path:
install_rabbit(rabbitmq_path)
except Exception as exc:
_log.error("Error installing RabbitMQ package {}".format(traceback.format_exc()))
_log.error('Error installing RabbitMQ package {}'.format(traceback.format_exc()))


def install_rabbit(rmq_install_dir):
# Install gevent friendly pika
pip('install', ['pika==1.2.0'], False, offline=False)
# try:
process = subprocess.Popen(["which", "erl"], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
process = subprocess.Popen(['which', 'erl'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
(output, error) = process.communicate()
if process.returncode != 0:
sys.stderr.write("ERROR:\n Unable to find erlang in path. Please install necessary pre-requisites. "
"Reference: https://volttron.readthedocs.io/en/latest/setup/index.html#steps-for-rabbitmq")
sys.stderr.write('ERROR:\n Unable to find erlang in path. Please install necessary pre-requisites. '
'Reference: https://volttron.readthedocs.io/en/latest/setup/index.html#steps-for-rabbitmq')

sys.exit(60)

if rmq_install_dir == default_rmq_dir and not os.path.exists(
default_rmq_dir):
os.makedirs(default_rmq_dir)
_log.info("\n\nInstalling Rabbitmq Server in default directory: " +
_log.info('\n\nInstalling Rabbitmq Server in default directory: ' +
default_rmq_dir)
else:
_log.info(
"\n\nInstalling Rabbitmq Server at {}".format(rmq_install_dir))
'\n\nInstalling Rabbitmq Server at {}'.format(rmq_install_dir))

valid_dir = os.access(rmq_install_dir, os.W_OK)
if not valid_dir:
raise ValueError("Invalid install directory. Directory should "
"exist and should have write access to user")
raise ValueError('Invalid install directory. Directory should '
'exist and should have write access to user')

rmq_home = os.path.join(rmq_install_dir, rabbitmq_server)
if os.path.exists(rmq_home) and \
os.path.exists(os.path.join(rmq_home, 'sbin/rabbitmq-server')):
_log.info("{} already contains {}. "
"Skipping rabbitmq server install".format(
_log.info('{} already contains {}. '
'Skipping rabbitmq server install'.format(
rmq_install_dir, rabbitmq_server))
else:
url = f"https://github.com/rabbitmq/rabbitmq-server/releases/download/v{rmq_version}/rabbitmq-server-generic-unix-{rmq_version}.tar.xz"
url = f'https://github.com/rabbitmq/rabbitmq-server/releases/download/v{rmq_version}/rabbitmq-server-generic-unix-{rmq_version}.tar.xz'
f = urlopen(url)
data = f.read()
filename = "rabbitmq-server.download.tar.xz"
with open(filename, "wb") as imgfile:
filename = 'rabbitmq-server.download.tar.xz'
with open(filename, 'wb') as imgfile:
imgfile.write(data)
_log.info("\nDownloaded rabbitmq server")
cmd = ["tar",
"-xf",
_log.info('\nDownloaded rabbitmq server')
cmd = ['tar',
'-xf',
filename,
"--directory=" + rmq_install_dir]
'--directory=' + rmq_install_dir]
subprocess.check_call(cmd)
_log.info("Installed Rabbitmq server at " + rmq_home)
_log.info('Installed Rabbitmq server at ' + rmq_home)
# enable plugins
cmd = [os.path.join(rmq_home, "sbin/rabbitmq-plugins"),
"enable", "rabbitmq_management",
"rabbitmq_federation",
"rabbitmq_federation_management",
"rabbitmq_shovel",
"rabbitmq_shovel_management",
"rabbitmq_auth_mechanism_ssl",
"rabbitmq_trust_store"]
cmd = [os.path.join(rmq_home, 'sbin/rabbitmq-plugins'),
'enable', 'rabbitmq_management',
'rabbitmq_federation',
'rabbitmq_federation_management',
'rabbitmq_shovel',
'rabbitmq_shovel_management',
'rabbitmq_auth_mechanism_ssl',
'rabbitmq_trust_store']
subprocess.check_call(cmd)

with open(os.path.expanduser("~/.volttron_rmq_home"), 'w+') as f:
with open(os.path.expanduser('~/.volttron_rmq_home'), 'w+') as f:
f.write(rmq_home)


Expand Down Expand Up @@ -295,7 +281,7 @@ def main(argv=sys.argv):
po.add_argument('--all', action='append_const', const='all', dest='optional_args')
for arg in extras_require:
if 'dnp' not in arg:
po.add_argument('--'+arg, action='append_const', const=arg, dest="optional_args")
po.add_argument('--'+arg, action='append_const', const=arg, dest='optional_args')

# Add rmq download actions.
rabbitmq = parser.add_argument_group('rabbitmq options')
Expand Down Expand Up @@ -396,7 +382,7 @@ def main(argv=sys.argv):
subprocess.check_call(args)


if __name__ == "__main__":
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
Expand Down
56 changes: 21 additions & 35 deletions debugging_utils/peerlist-watcher.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
# -*- coding: utf-8 -*- {{{
# vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et:
# ===----------------------------------------------------------------------===
#
# Copyright 2020, Battelle Memorial Institute.
# Component of Eclipse VOLTTRON
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# ===----------------------------------------------------------------------===
#
# http://www.apache.org/licenses/LICENSE-2.0
# Copyright 2023 Battelle Memorial Institute
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This material was prepared as an account of work sponsored by an agency of
# the United States Government. Neither the United States Government nor the
# United States Department of Energy, nor Battelle, nor any of their
# employees, nor any jurisdiction or organization that has cooperated in the
# development of these materials, makes any warranty, express or
# implied, or assumes any legal liability or responsibility for the accuracy,
# completeness, or usefulness or any information, apparatus, product,
# software, or process disclosed, or represents that its use would not infringe
# privately owned rights. Reference herein to any specific commercial product,
# process, or service by trade name, trademark, manufacturer, or otherwise
# does not necessarily constitute or imply its endorsement, recommendation, or
# favoring by the United States Government or any agency thereof, or
# Battelle Memorial Institute. The views and opinions of authors expressed
# herein do not necessarily state or reflect those of the
# United States Government or any agency thereof.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# PACIFIC NORTHWEST NATIONAL LABORATORY operated by
# BATTELLE for the UNITED STATES DEPARTMENT OF ENERGY
# under Contract DE-AC05-76RL01830
# ===----------------------------------------------------------------------===
# }}}

"""
Expand Down Expand Up @@ -61,7 +47,7 @@

def get_volttron_home():
try:
with open("/tmp/volttron_home.txt", "r") as fp:
with open('/tmp/volttron_home.txt', 'r') as fp:
return fp.read().strip()
except FileNotFoundError:
return None
Expand All @@ -73,7 +59,7 @@ def get_public_private_key(volttron_home):


volttron_home = get_volttron_home()
last_output = ""
last_output = ''

agent: Optional[Agent] = None
while True:
Expand All @@ -86,26 +72,26 @@ def get_public_private_key(volttron_home):

os.environ['VOLTTRON_HOME'] = volttron_home
public, secret = get_public_private_key(volttron_home)
last_output = f"Attempting connection {volttron_home}"
last_output = f'Attempting connection {volttron_home}'
print(last_output)
agent = build_agent(volttron_home=volttron_home,
identity="peer.finder",
identity='peer.finder',
publickey=public,
secretkey=secret,
serverkey=public)

if agent:
try:
with gevent.Timeout(5):
next_last_output = f"Peerlist: {agent.vip.peerlist().get()}"
next_last_output = f'Peerlist: {agent.vip.peerlist().get()}'
if next_last_output != last_output:
last_output = next_last_output
print(last_output)
except gevent.Timeout:
agent.core.stop()
agent = None
else:
next_last_output = "waiting on file."
next_last_output = 'waiting on file.'
if next_last_output != last_output:
last_output = next_last_output
print(last_output)
Expand Down
45 changes: 15 additions & 30 deletions deprecated/Ambient/setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
# -*- coding: utf-8 -*- {{{
# vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et:
# ===----------------------------------------------------------------------===
#
# Copyright 2020, Battelle Memorial Institute.
# Component of Eclipse VOLTTRON
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# ===----------------------------------------------------------------------===
#
# http://www.apache.org/licenses/LICENSE-2.0
# Copyright 2023 Battelle Memorial Institute
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This material was prepared as an account of work sponsored by an agency of
# the United States Government. Neither the United States Government nor the
# United States Department of Energy, nor Battelle, nor any of their
# employees, nor any jurisdiction or organization that has cooperated in the
# development of these materials, makes any warranty, express or
# implied, or assumes any legal liability or responsibility for the accuracy,
# completeness, or usefulness or any information, apparatus, product,
# software, or process disclosed, or represents that its use would not infringe
# privately owned rights. Reference herein to any specific commercial product,
# process, or service by trade name, trademark, manufacturer, or otherwise
# does not necessarily constitute or imply its endorsement, recommendation, or
# favoring by the United States Government or any agency thereof, or
# Battelle Memorial Institute. The views and opinions of authors expressed
# herein do not necessarily state or reflect those of the
# United States Government or any agency thereof.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# PACIFIC NORTHWEST NATIONAL LABORATORY operated by
# BATTELLE for the UNITED STATES DEPARTMENT OF ENERGY
# under Contract DE-AC05-76RL01830
# ===----------------------------------------------------------------------===
# }}}

from os import path
Expand Down Expand Up @@ -73,4 +59,3 @@
]
}
)

Loading

0 comments on commit 961a96c

Please sign in to comment.