I can confirm, the Java HTTP libraries support them. You can see examples (Rules DSL but the Java will still be the same) at:
You could also use executeCommandLine or subprocess (subprocess works a bit better in my experience) to call curl as a work around. Here is an example using subprocess and wget (I’m just grabbing an icon).
from core.rules import rule
from core.triggers import when
from configuration import weather_icon_path
import subprocess
from javax.imageio import ImageIO
from java.io import File
@rule("Weather Icon",
description="Copy the current weather conditions icon",
tags=["weather"])
@when("Item vWeather_Conditions_Icon changed")
@when("System started")
def cond_icon(event):
"""
Download the weather conditions icon from DarkSky and convert it from gif to
png.
"""
# OpenWeatherMap
# cond_icon.log.info("Fetching weather conditions icon to {} from {}"
# .format(weather_icon_path, items["vWeather_Conditions_Icon"]))
#
# results = subprocess.check_output(['/usr/bin/wget', '-q', '-O',
# weather_icon_path,
# str(items["vWeather_Conditions_Icon"])])
#
# input_file = File(weather_icon_path)
# if not input_file.exists():
# cond_icon.log.warn("Failed to fetch the weather icon!")
# return
#
# output_file = File(weather_icon_path.replace('gif', 'png'))
# ImageIO.write( ImageIO.read(input_file), 'png', output_file)
#
# results = subprocess.check_output(['rm', weather_icon_path])
# DarkSky
cond_icon.log.info("Fetching the weather conditions icon... {}".format(ir.getItem("vWeather_Conditions_Icon").state))
dl = subprocess.Popen(['/usr/bin/wget', '-qO-',
'http://argus:8080/rest/items/vWeather_Conditions_Icon/state'],
stdout=subprocess.PIPE)
dd = subprocess.Popen(['/bin/dd', 'bs=22', 'skip=1'], stdin=dl.stdout, stdout=subprocess.PIPE)
dl.wait()
f = open(weather_icon_path, "w")
subprocess.call(['/usr/bin/base64', '-d'], stdout=f, stdin=dd.stdout)
dd.wait()
Note, the ImageIO class I use to convert the gif to png is a Java class.
If you make a helper I strongly recommend using subprocess instead of executeCommandLine. It can be quite challenging if not impossible to get executeCommandLine to work sometimes. The way the arguments are pass as an array or tuple in subprocess helps avoid the whole @@ nonsense. In fact, if you look at the simple command I try to run in the commented out OpenWeatherMap example above, I never was able to get that simple wget to run using executeCommandLine. I used subprocess out of desperation and was very happy with how easy it was to use.