Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions archApp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include $(TOP)/configure/CONFIG_PY

PY += bplreport.py
DB += applmetrics.db
DB += bplstorage.db

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PY
Expand Down
27 changes: 15 additions & 12 deletions archApp/bplreport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import time, sched, urllib2, json
import time, sched, urllib, json
import urllib.request # https://stackoverflow.com/questions/37042152/python-3-5-1-urllib-has-no-attribute-request
from devsup.db import IOScanListBlock
from devsup.hooks import initHook
from devsup.util import StoppableThread
Expand All @@ -20,19 +21,21 @@ def fail(self):

def process(self):
self.result = None
R = urllib2.urlopen(self.url, timeout=3)
R = None
try:
R = urllib.request.urlopen(self.url, timeout=3)
if R.getcode()!=200:
print 'Fail',R.getcode(), self.url
print ('Fail',R.getcode(), self.url)
self.result = None
return
self.result = json.load(R)
except:
print 'Error fetching',self.url
print ('Error fetching',self.url)
import traceback
traceback.print_exc()
finally:
R.close()
if R is not None:
R.close()
self.result_time = time.time()
self.scan.interrupt(reason = self.result)

Expand All @@ -51,23 +54,23 @@ def _proc(self, R):
try:
R.process()
except:
print 'Error in processing',R.url
print ('Error in processing',R.url)
import traceback
traceback.print_exc()
R.fail()

def run(self):
self._S = S = sched.scheduler(time.time, self._sleep)

for R in BPLReport.reports.itervalues():
for R in iter(BPLReport.reports.values()):
S.enter(0, 0, self._proc, (R,))

try:
S.run()
except self._Done:
print 'BPL worker exit'
print ('BPL worker exit')
except:
print 'Error in scheduler'
print ('Error in scheduler')
import traceback
traceback.print_exc()

Expand All @@ -76,13 +79,13 @@ def run(self):
@initHook("AfterIocRunning")
def _startWorker():
_worker.start()
print 'BPL worker started'
print ('BPL worker started')

@initHook("AtIocExit")
def _stopWorker():
print 'BPL worker stopping'
print ('BPL worker stopping')
_worker.join()
print 'BPL worker stopped'
print ('BPL worker stopped')

class ReportItem(object):
raw = True
Expand Down
8 changes: 0 additions & 8 deletions devsupApp/src/devsup/disect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
from __future__ import print_function

import sys, gc, inspect, time
try:
InstanceType = None
from types import InstanceType
except ImportError:
pass # py3

class StatsDelta(object):
"""GC statistics tracking.
Expand Down Expand Up @@ -82,9 +77,6 @@ def gcstats():
if K is StatsDelta:
continue # avoid counting ourselves

elif InstanceType is not None and K is InstanceType: # instance of an old-style class
K = getattr(obj, '__class__', K)

# Track types as strings to avoid holding references
K = str(K)

Expand Down
25 changes: 25 additions & 0 deletions iocBoot/env_vars.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@echo off
REM This script extracts the:
REM PATH to the Python install. On Windows, this is not a system path.
REM The value of the used Python version makefile variable. It is applied to the executable to be loaded.
set TOP=%~dp0..
set CONFIG_PY=%TOP%\configure\os\CONFIG_PY.Common.windows-x64
REM https://stackoverflow.com/questions/232747/read-environment-variables-from-file-in-windows-batch-cmd-exe
setlocal EnableDelayedExpansion
for /F "tokens=1,2 delims==" %%i in ('type %CONFIG_PY%') do (
set rawtoken=%%i
REM rawtoken still ends with the " :" of the " := " text.
set token=!rawtoken:~0,-2%!
set rawvalue=%%j
REM rawvalue still begins with the " " of the " := " text.
set value=!rawvalue:~1%!
if "!token!"=="PY_VER" (
set PY_VER="!value!"
)
if "!token!"=="PY_LIBDIRS" (
REM remove the "\libs" from the end of the string
set PYTHON=!value:~0,-5%!
)
)
REM https://stackoverflow.com/questions/15494688/batch-script-make-setlocal-variable-accessed-by-other-batch-files
endlocal & set PATH=%PYTHON%;C:\Windows & set PY_VER=%PY_VER%
6 changes: 6 additions & 0 deletions iocBoot/iocapplmon/st.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
set OLD_PATH=%PATH%
call ..\env_vars.bat
call dllPath.bat
%TOP%\bin\windows-x64\softIocPy%PY_VER%.exe st.cmd
set PATH=%OLD_PATH%
6 changes: 6 additions & 0 deletions iocBoot/iocarchivemon/st.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
set OLD_PATH=%PATH%
call ..\env_vars.bat
call dllPath.bat
%TOP%\bin\windows-x64\softIocPy%PY_VER%.exe st.cmd
set PATH=%OLD_PATH%
8 changes: 8 additions & 0 deletions iocBoot/iocweatherbnl/st.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
REM requires the pymetar module installed.
set OLD_PATH=%PATH%
call ..\env_vars.bat
call dllPath.bat
%TOP%\bin\windows-x64\softIocPy%PY_VER%.exe st.cmd
set PATH=%OLD_PATH%

6 changes: 3 additions & 3 deletions iocBoot/iocweatherbnl/st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ cd("$(TOP)")

#epicsEnvSet("PYTHONPATH", "${TOP}/python/$(ARCH)")

dbLoadRecords("db/weather.db","P=CF:Ext{KISP},LOC=KISP")
#dbLoadRecords("db/weather.db","P=CF:Ext{KHWV},LOC=KHWV")
dbLoadRecords("db/weather.db","P=CF:Ext{EGTK},LOC=EGTK")
dbLoadRecords("db/weather.db","P=CF:Ext{KISP},LOC=KISP") # Long Island MacArthur Airport
#dbLoadRecords("db/weather.db","P=CF:Ext{KHWV},LOC=KHWV") # Brookhaven Calabro Airport
dbLoadRecords("db/weather.db","P=CF:Ext{EGTK},LOC=EGTK") # London Oxford Airport (Kidlington)

iocInit()

Expand Down
Loading