Skip to content

Commit

Permalink
Merge pull request #2915 from Siecje/whitespace
Browse files Browse the repository at this point in the history
Fix whitespace
  • Loading branch information
craig8 authored Jun 8, 2023
2 parents 6881c4a + 213c76a commit fd7a3e9
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
count = count + db.data.find(
{"topic_id":x['_id'],
"ts":{"$gte":s_dt, "$lt":e_dt}}).count()
print (count)
print ("time taken: {}".format(datetime.datetime.now()-start))
print(count)
print("time taken: {}".format(datetime.datetime.now() - start))
12 changes: 6 additions & 6 deletions deprecated/MongodbHistorian/scripts/rollup_data_by_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def execute_batch(table_type, bulk, count, topic_id, topic_name):
"bulk execute of {} data for {}:{}.\nnumber of op sent to "
"bulk execute ({}) does not match nModified count".format(
table_type, topic_id, topic_name, count))
print ("bulk execute result {}".format(result))
print("bulk execute result {}".format(result))
errors = True
except BulkWriteError as ex:
print(str(ex.details))
Expand Down Expand Up @@ -338,7 +338,7 @@ def init_hourly_data(db, data_collection, start_dt, end_dt):
if __name__ == '__main__':
start = datetime.utcnow()

print ("Starting rollup of data from {} to {}. current time: {}".format(
print("Starting rollup of data from {} to {}. current time: {}".format(
start_date, end_date, start))

pool = Pool(size=10)
Expand Down Expand Up @@ -370,13 +370,13 @@ def init_hourly_data(db, data_collection, start_dt, end_dt):
source_db = connect_mongodb(local_source_params)
s_dt = datetime.strptime(start_date, '%d%b%YT%H:%M:%S.%f')
e_dt = datetime.strptime(end_date, '%d%b%YT%H:%M:%S.%f')
print ("Starting init of tables")
print("Starting init of tables")
init_start = datetime.utcnow()
init_daily_data(source_db,
source_tables['data_table'],
s_dt,
e_dt)
print ("Total time for init of daily data "
print("Total time for init of daily data "
"between {} and {} : {} "
"".format(start_date, end_date,
datetime.utcnow() - init_start))
Expand All @@ -385,7 +385,7 @@ def init_hourly_data(db, data_collection, start_dt, end_dt):
source_tables['data_table'],
s_dt,
e_dt)
print ("Total time for init of hourly data "
print("Total time for init of hourly data "
"between {} and {} : {} "
"".format(start_date, end_date,
datetime.utcnow() - init_start))
Expand Down Expand Up @@ -419,7 +419,7 @@ def init_hourly_data(db, data_collection, start_dt, end_dt):
print("Exception processing data: {}".format(e.args))
finally:
pool.kill()
print ("Total time for roll up of data : {}".format(
print("Total time for roll up of data : {}".format(
datetime.utcnow() - start))
if log:
log.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@


def connect_mongodb(connection_params):
print ("setup mongodb")
print("setup mongodb")
mongo_conn_str = 'mongodb://{user}:{passwd}@{host}:{port}/{database}'
if connection_params.get('authSource'):
mongo_conn_str = mongo_conn_str+ '?authSource={authSource}'
params = connection_params
mongo_conn_str = mongo_conn_str.format(**params)
print (mongo_conn_str)
print(mongo_conn_str)
mongo_client = pymongo.MongoClient(mongo_conn_str)
db = mongo_client[connection_params['database']]
return db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The agent listens to schedule announcements from the actuator and then issues a
@PubSub.subscribe('pubsub', topics.ACTUATOR_SCHEDULE_ANNOUNCE(campus='campus',
building='building',unit='unit'))
def actuate(self, peer, sender, bus, topic, headers, message):
print ("response:",topic,headers,message)
print("response:", topic, headers, message)
if headers[headers_mod.REQUESTER_ID] != agent_id:
return
'''Match the announce for our fake device with our ID
Expand Down
2 changes: 1 addition & 1 deletion examples/CAgent/c_agent/driver/cdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def so_lookup_function(shared_object, function_name):
return function

class CRegister(BaseRegister):
def __init__(self,read_only, pointName, units, description = ''):
def __init__(self, read_only, pointName, units, description=''):
super(CRegister, self).__init__("byte", read_only, pointName, units, description = '')


Expand Down
2 changes: 1 addition & 1 deletion examples/ConfigActuation/tests/test_config_actuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def publish_agent(request, volttron_instance):
assert process.returncode == 0

# Add platform driver configuration files to config store.
cmd = ['volttron-ctl', 'config', 'store',PLATFORM_DRIVER,
cmd = ['volttron-ctl', 'config', 'store', PLATFORM_DRIVER,
'fake.csv', 'fake_unit_testing.csv', '--csv']
process = Popen(cmd, env=volttron_instance.env,
cwd='scripts/scalability-testing',
Expand Down
2 changes: 1 addition & 1 deletion examples/DataPuller/puller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def on_message(self, peer, sender, bus, topic, headers, message):
_log.debug("data in capture_data {}".format(data))
if isinstance(data, dict):
data = data
elif isinstance(data, (int,float)):
elif isinstance(data, (int, float)):
data = data
# else:
# data = data[0]
Expand Down
4 changes: 2 additions & 2 deletions examples/ExampleMatlabApplication/matlab/matlab_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
print("Sending config_params")
config_params = {"zone_temperature_list": ["ZoneTemperature1", "ZoneTemperature2"],
"zone_setpoint_list": ["ZoneTemperatureSP1", "ZoneTemperatureSP2"]}
config_socket.send_json(config_params,zmq.NOBLOCK)
config_socket.send_json(config_params, zmq.NOBLOCK)

print("Sending data")
data = {"zone_temperature_list": ["72.3", "78.5"]}
data_socket.send_json(data,zmq.NOBLOCK)
data_socket.send_json(data, zmq.NOBLOCK)

except ZMQError:
print("No Matlab process running to send message")
Expand Down
8 changes: 4 additions & 4 deletions examples/ExampleSubscriber/subscriber/subscriber_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def lookup_data(self):
order = "FIRST_TO_LAST").get(timeout=10)
print('Query Result', result)
except Exception as e:
print ("Could not contact historian. Is it running?")
print("Could not contact historian. Is it running?")
print(e)

@Core.schedule(periodic(10))
Expand All @@ -176,9 +176,9 @@ def pub_fake_data(self):
'''

#Make some random readings
oat_reading = random.uniform(30,100)
mixed_reading = oat_reading + random.uniform(-5,5)
damper_reading = random.uniform(0,100)
oat_reading = random.uniform(30, 100)
mixed_reading = oat_reading + random.uniform(-5, 5)
damper_reading = random.uniform(0, 100)

# Create a message for all points.
all_message = [{'OutsideAirTemperature': oat_reading, 'MixedAirTemperature': mixed_reading,
Expand Down
4 changes: 2 additions & 2 deletions examples/FNCS/fncs_example/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def fncs_example(config_path, **kwargs):
stop_agent_when_sim_complete = config.get("stop_agent_when_sim_complete", False)
subscription_topic = config.get("subscription_topic", None)
return FncsExample(topic_mapping=topic_mapping, federate_name=federate, broker_location=broker_location,
time_delta=time_delta,subscription_topic=subscription_topic, sim_length=sim_length,
time_delta=time_delta, subscription_topic=subscription_topic, sim_length=sim_length,
stop_agent_when_sim_complete=stop_agent_when_sim_complete, **kwargs)


Expand All @@ -56,7 +56,7 @@ class FncsExample(Agent):
"""

def __init__(self, topic_mapping, federate_name=None, broker_location="tcp://localhost:5570",
time_delta="1s",subscription_topic=None, simulation_start_time=None, sim_length="10s",
time_delta="1s", subscription_topic=None, simulation_start_time=None, sim_length="10s",
stop_agent_when_sim_complete=False, **kwargs):
super(FncsExample, self).__init__(enable_fncs=True, enable_store=False, **kwargs)
_log.debug("vip_identity: " + self.core.identity)
Expand Down
2 changes: 1 addition & 1 deletion examples/HELICS/helics_federate.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def federate_example(config_path):
endid = {}
subid = {}
pubid = {}
for i in range(0,endpoint_count):
for i in range(0, endpoint_count):
endid["m{}".format(i)] = h.helicsFederateGetEndpointByIndex(fed, i)
end_name = h.helicsEndpointGetName(endid["m{}".format(i)])
logger.info( 'Registered Endpoint ---> {}'.format(end_name))
Expand Down
10 changes: 6 additions & 4 deletions examples/MarketAgents/AHUAgent/ahu/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ def ahu_agent(config_path, **kwargs):
c3= config.get('c3')
COP= config.get('COP')
verbose_logging= config.get('verbose_logging', True)
return AHUAgent(air_market_name,electric_market_name,agent_name,subscribing_topic,c0,c1,c2,c3,COP,verbose_logging, **kwargs)
return AHUAgent(air_market_name, electric_market_name, agent_name,
subscribing_topic, c0, c1, c2, c3, COP, verbose_logging, **kwargs)

class AHUAgent(MarketAgent, AhuChiller):
"""
The SampleElectricMeterAgent serves as a sample of an electric meter that
sells electricity for a single building at a fixed price.
"""
def __init__(self, air_market_name, electric_market_name, agent_name,subscribing_topic,c0,c1,c2,c3,COP,verbose_logging, **kwargs):
def __init__(self, air_market_name, electric_market_name, agent_name,
subscribing_topic, c0, c1, c2, c3, COP, verbose_logging, **kwargs):
super(AHUAgent, self).__init__(verbose_logging, **kwargs)

self.air_market_name = air_market_name
Expand Down Expand Up @@ -155,10 +157,10 @@ def create_air_supply_curve(self, electric_price, electric_quantity):
supply_curve = PolyLine()
price = 65
quantity = 100000
supply_curve.add(Point(price=price,quantity=quantity))
supply_curve.add(Point(price=price, quantity=quantity))
price = 65
quantity = 0 # negative quantities are not real -1*10000
supply_curve.add(Point(price=price,quantity=quantity))
supply_curve.add(Point(price=price, quantity=quantity))
return supply_curve

def create_electric_demand_curve(self, aggregate_air_demand):
Expand Down
2 changes: 1 addition & 1 deletion examples/SchedulerExample/schedule_example/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def startup(self, sender, **kwargs):
@PubSub.subscribe('pubsub', topics.ACTUATOR_SCHEDULE_ANNOUNCE(campus='campus',
building='building',unit='unit'))
def actuate(self, peer, sender, bus, topic, headers, message):
print ("response:",topic,headers,message)
print("response:", topic, headers, message)
if headers[headers_mod.REQUESTER_ID] != agent_id:
return
'''Match the announce for our fake device with our ID
Expand Down
2 changes: 1 addition & 1 deletion scripts/tagging_scripts/insert_id_and_ref_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def mongo_insert(tags, execute_now=False):
try:
result = mongo_bulk.execute()
if result['nInserted'] != mongo_batch_size:
print ("bulk execute result {}".format(result))
print("bulk execute result {}".format(result))
errors = True
except BulkWriteError as ex:
print(str(ex.details))
Expand Down
26 changes: 13 additions & 13 deletions services/core/ActuatorAgent/tests/test_actuator_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_request_new_schedule(publish_agent, cancel_schedules, taskid, expected_
:param cancel_schedules: fixture used to cancel the schedule at the end of
test so that other tests can use the same device and time slot
"""
print ("\n**** test_schedule_success ****")
print("\n**** test_schedule_success ****")
# used by cancel_schedules
agentid = TEST_AGENT
cancel_schedules.append({'agentid': agentid, 'taskid': taskid})
Expand Down Expand Up @@ -460,7 +460,7 @@ def test_request_new_schedule_should_suceed_on_preempt_active_task(publish_agent
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_schedule_preempt_active_task ****")
print("\n**** test_schedule_preempt_active_task ****")
# used by cancel_schedules
agentid = 'new_agent'
taskid = 'task_high_priority2'
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_request_new_schedule_should_return_failure_on_preempt_active_task(publi
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_schedule_preempt_error_active_task ****")
print("\n**** test_schedule_preempt_error_active_task ****")
# used by cancel_schedules
agentid = TEST_AGENT
taskid = 'task_low_priority3'
Expand Down Expand Up @@ -713,7 +713,7 @@ def test_request_new_schedule_should_succeed_on_preempt_future_task(publish_agen
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_schedule_preempt_future_task ****")
print("\n**** test_schedule_preempt_future_task ****")
# used by cancel_schedules
agentid = 'new_agent'
taskid = 'task_high_priority4'
Expand Down Expand Up @@ -789,7 +789,7 @@ def test_request_new_schedule_should_return_failure_on_conflicting_time_slots(pu
:param publish_agent: fixture invoked to setup all agents necessary and
returns an instance of Agent object used for publishing
"""
print ("\n**** test_schedule_conflict_self ****")
print("\n**** test_schedule_conflict_self ****")
# used by cancel_schedules
taskid = 'task_self_conflict'
start = str(datetime.now())
Expand Down Expand Up @@ -868,7 +868,7 @@ def test_request_new_schedule_should_succeed_on_overlap_time_slots(publish_agent
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_schedule_overlap_success ****")
print("\n**** test_schedule_overlap_success ****")
# set agentid and task id for cancel_schedules fixture
agentid = TEST_AGENT
taskid = 'task_overlap'
Expand Down Expand Up @@ -902,7 +902,7 @@ def test_request_cancel_schedule_should_succeed(publish_agent):
:param publish_agent: fixture invoked to setup all agents necessary and
returns an instance of Agent object used for publishing
"""
print ("\n**** test_cancel_success ****")
print("\n**** test_cancel_success ****")

start = str(datetime.now())
end = str(datetime.now() + timedelta(seconds=2))
Expand Down Expand Up @@ -940,7 +940,7 @@ def test_request_cancel_schedule_should_return_failure_on_invalid_taskid(publish
returns an instance
of Agent object used for publishing
"""
print ("\n**** test_cancel_error_invalid_taskid ****")
print("\n**** test_cancel_error_invalid_taskid ****")
result = publish_agent.vip.rpc.call(
PLATFORM_ACTUATOR,
REQUEST_CANCEL_SCHEDULE,
Expand All @@ -963,7 +963,7 @@ def test_get_point_should_succeed(publish_agent):
:param publish_agent: fixture invoked to setup all agents necessary and
returns an instance of Agent object used for publishing
"""
print ("\n**** test_get_default ****")
print("\n**** test_get_default ****")

result = publish_agent.vip.rpc.call(
PLATFORM_ACTUATOR, # Target agent
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def test_revert_point_should_succeed(publish_agent, cancel_schedules):
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_set_float_value ****")
print("\n**** test_set_float_value ****")
taskid = 'test_revert_point'
agentid = TEST_AGENT
cancel_schedules.append({'agentid': agentid, 'taskid': taskid})
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def test_revert_point_with_point_should_succeed(publish_agent, cancel_schedules)
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_set_float_value ****")
print("\n**** test_set_float_value ****")
taskid = 'test_revert_point'
agentid = TEST_AGENT
cancel_schedules.append({'agentid': agentid, 'taskid': taskid})
Expand Down Expand Up @@ -1380,7 +1380,7 @@ def test_set_point_raises_value_error(publish_agent, cancel_schedules):
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_set_value_error ****")
print("\n**** test_set_value_error ****")
agentid = TEST_AGENT
taskid = 'task_set_value_error'
cancel_schedules.append({'agentid': agentid, 'taskid': taskid})
Expand Down Expand Up @@ -1562,7 +1562,7 @@ def test_set_point_raises_remote_error_on_lock_failure(publish_agent, cancel_sch
:param cancel_schedules: fixture used to cancel the schedule at the end
of test so that other tests can use the same device and time slot
"""
print ("\n**** test_set_float_value ****")
print("\n**** test_set_float_value ****")
agentid = TEST_AGENT

with pytest.raises(RemoteError):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def test_old_config(volttron_instances, forwarder):
# gevent.sleep(1) # wait for topic to be forwarded and callback to happen
#
# # assert query_agent.callback.call_count == 1
# print ('call args ', query_agent.callback.call_args_list)
# print('call args ', query_agent.callback.call_args_list)
# # assert query_agent.callback.call_args[0][1] == 'platform.actuator'
# assert query_agent.callback.call_args[0][3] == \
# topics.ACTUATOR_SCHEDULE_RESULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def mongo_insert(tags, execute_now=False):
try:
result = mongo_bulk.execute()
if result['nInserted'] != mongo_batch_size:
print ("bulk execute result {}".format(result))
print("bulk execute result {}".format(result))
errors = True
except BulkWriteError as ex:
print(str(ex.details))
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_mongo_tags():
"equip_tag 7": {"$gt": 2}}, {"topic_prefix": 1})
topics = [record['_id'] for record in tags_cursor]
print("example query result: {}".format(topics))
print ("Time taken by mongo for result: {}".format(
print("Time taken by mongo for result: {}".format(
datetime.datetime.now() - start))


Expand All @@ -230,8 +230,8 @@ def test_sqlite_tags():
' INTERSECT '
'select topic_prefix from test_tags where tag = "equip_tag 7" and '
'value > 2')
print ("topics :{}".format(tags_cursor.fetchall()))
print ("Time taken by sqlite for result: {}".format(
print("topics :{}".format(tags_cursor.fetchall()))
print("Time taken by sqlite for result: {}".format(
datetime.datetime.now() - start))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_existed_file(self, file_dir, file_name):
if file_dir:
while True:
if not os.path.exists("{0}/{1}".format(file_dir, file_name)):
print ("'{0}' file '{1}' does not exist in the directory '{2}'".format(file_type,
print("'{0}' file '{1}' does not exist in the directory '{2}'".format(file_type,
file_name,
file_dir))
if file_name == 'maps.yaml':
Expand Down Expand Up @@ -817,7 +817,7 @@ def do_delete_volttron_config(self, line):
print("DRIVER NAME".ljust(16) + "| VOLTTRON PATH")
for d in drivers.keys():
print("{0:15} | {1}".format(d, drivers[d]))
print ("\nEnter driver name to delete: ", end='')
print("\nEnter driver name to delete: ", end='')
driver_name = input()

if driver_name not in drivers:
Expand Down
Loading

0 comments on commit fd7a3e9

Please sign in to comment.