# Which is Better Gateway Schedule or Gateway Timer script

**URL:** <https://forum.inductiveautomation.com/t/which-is-better-gateway-schedule-or-gateway-timer-script/75073>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 15, 2023, 12:22pm UTC](https://forum.inductiveautomation.com/t/which-is-better-gateway-schedule-or-gateway-timer-script/75073 "2023-06-15T12:22:17Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 15, 2023, 2:44pm UTC](https://forum.inductiveautomation.com/t/which-is-better-gateway-schedule-or-gateway-timer-script/75073/9 "2023-06-15T14:44:51Z")

</div>

I only looked at UpdateOEETag\_Script here is what I see.

Don't do this:

```python
sys.exit()

```

> [@Question about Exit()](https://forum.inductiveautomation.com/t/question-about-exit/74731/4):
>
> sys.exit() and the Java equivalent aren't designed to return early from a method, they're designed to end the execution of the program, and the only reason your Ignition Gateway / JVM doesn't cease to exist after that is because we've hooked into prevent it. It's not meant for what you're using it for.

You can unpack pyDataSets so your for loop can be written as:

```python
for machineName,zoneName,lineId,facilityName,attachedTo in allShifts:

```

If you do that, then there is no need for the if statement prior to the loop, if allShifts is empty, it just wont run. So remove:

```auto
if(len(allShifts) > 0):

```

What is the point of the `try: except:` block in the for loop if you're not going to log an issue? Also, I really don't think that you need it here, but since you're calling external functions perhaps you do?

This:

```python
if (len(result) > 0):

```

Should be written as

```python
if result:

```

You've already set count to 0 so there is not need for the else in this if statement, but meh...

I don't know what you're doing in the `HistorianData` functions but you are calling `getOeewithZone()` and `getUnattendedDT()` multiple times, perhaps seeing the code for those functions we could provide some more insight.

I would certainly combine all of your tag writes into a single function call, and remove the unneeded string conversions.

Something like:

```auto
tags = ['OEE','Availablity','Downtime','GoodCount','Performance','Quality','Runtime','Scrap','UnattendedDT','IsHoliday','Department']
tagPaths = ['{0}{1}/{2}/{3}'.format(machineOEEPath,facilityName,machineName,tag) for tag in tags]
tagValues = [oee,availability,totalDownTime,goodCount,performance,quality,runTime,scrapCount,count,Holiday,attachedTo]
system.tag.writeAsync(tagPaths,tagValues)

```

You're collecting error info to log, but then not actually logging it in you're final except block.

There is also potentially a typo in one of your tag paths. You have `'UnattendentDT'` but I think you might mean `'UnattendedDT'`?

---

_[View the full topic](https://forum.inductiveautomation.com/t/which-is-better-gateway-schedule-or-gateway-timer-script/75073)._
