Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
akbooer committed Aug 5, 2016
2 parents fdf230e + f02508a commit ebfc6cc
Show file tree
Hide file tree
Showing 39 changed files with 2,337 additions and 2,117 deletions.
24 changes: 21 additions & 3 deletions Utilities/openLuup_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ p "openLuup_install 2016.06.08 @akbooer"
local http = require "socket.http"
local https = require "ssl.https"
local ltn12 = require "ltn12"
local lfs = require "lfs"

p "getting latest openLuup version tar file from GitHub..."

Expand All @@ -34,10 +35,27 @@ _, code = http.request{

assert (code == 200, "GitHub download failed with code " .. code)

p "initialising..."
p "creating required files and folders"
lfs.mkdir "files"
lfs.mkdir "icons"

local vfs = require "openLuup.virtualfilesystem"

local function add_vfs_file (name)
local f = io.open (name, "wb")
f: write (vfs.read (name))
f: close ()
end

add_vfs_file "index.html"

local o = require "openLuup.plugins"
o.add_ancillary_files ()
local reload = "openLuup_reload"
local pathSeparator = package.config:sub(1,1) -- thanks to @vosmont for this Windows/Unix discriminator
if pathSeparator ~= '/' then reload = reload .. ".bat" end -- Windows version

add_vfs_file (reload)

p "initialising..."

x "chmod a+x openLuup_reload"

Expand Down
44 changes: 0 additions & 44 deletions VeraBridge/D_VeraBridge.json

This file was deleted.

30 changes: 0 additions & 30 deletions VeraBridge/D_VeraBridge.xml

This file was deleted.

15 changes: 0 additions & 15 deletions VeraBridge/I_VeraBridge.xml

This file was deleted.

12 changes: 0 additions & 12 deletions VeraBridge/S_VeraBridge.xml

This file was deleted.

Binary file added icons/AltAppStore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/VeraBridge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 56 additions & 18 deletions openLuup/L_AltAppStore.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

local ABOUT = {
NAME = "AltAppStore",
VERSION = "2016.06.21",
VERSION = "2016.07.18",
DESCRIPTION = "update plugins from Alternative App Store",
AUTHOR = "@akbooer / @amg0 / @vosmont",
COPYRIGHT = "(c) 2013-2016",
Expand All @@ -19,9 +19,9 @@ local ABOUT = {
-- Plugin for Vera and openLuup
--
-- The Alternative App Store is a collaborative effort:
-- Web: @vosmont
-- (Alt)UI: @amg0
-- Plugin: @akbooer
-- Web/database: @vosmont
-- (Alt)UI: @amg0
-- Plugin: @akbooer
--
--[[
Expand All @@ -40,6 +40,7 @@ and partially modelled on the InstalledPlugins2 structure in Vera user_data.

-- 2016.06.20 use optional target repository parameter for final download destination
-- 2016.06.21 luup.create_device didn't work for UI7, so use action call for all systems
-- 2016.06.22 slightly better log messages for <run> and <job> phases, add test request argument

local https = require "ssl.https"
local lfs = require "lfs"
Expand Down Expand Up @@ -242,7 +243,7 @@ function GitHub (archive) -- global for access by other modules
end

--
-- End of gitHub module
-- End of GitHub module
--
-------------------------------------------------------

Expand Down Expand Up @@ -278,16 +279,15 @@ local function install_if_missing (meta)
local ip, mac, hidden, invisible, parent, room
local altid = ''
_log ("installing " .. name)
local devNo = create_device (device_type, altid, name, device_file,
create_device (device_type, altid, name, device_file,
device_impl, ip, mac, hidden, invisible, parent, room, pluginnum, statevariables)
return devNo
end

local devNo
-- install_if_missing()
if device_type and not present (device_type) then
devNo = install()
install()
return true
end
return devNo
end

local function file_copy (source, destination)
Expand Down Expand Up @@ -355,7 +355,7 @@ local AltAppStore =
AutoUpdate = "0",
VersionMajor = "not",
VersionMinor = "installed",
id = "AltAppStore", -- TODO: replace with real id once in MiOS App Store?
id = "AltAppStore",
-- timestamp = os.time(),
Files = {},
Devices = {
Expand Down Expand Up @@ -429,10 +429,19 @@ local next_file -- download iterator
local downloads -- location for downloads
local total -- total file transfer size
local files -- files list
local test

function update_plugin_run(args)
_log "starting <run> phase..."

-- p.metadata = p.metadata or json.encode (AltAppStore) -- TESTING ONLY!
test = false
if args.test then
_log "test <run> phase..."
test = tostring (args.test)
return true
end

_log "starting <run> phase..."
meta = json.decode (args.metadata)

if type (meta) ~= "table" then
Expand Down Expand Up @@ -477,7 +486,7 @@ function update_plugin_run(args)
display ("Downloading...", p.Title or '?')
total = 0
files = {}
_log "starting <job> phase..."
_log "scheduling <job> phase..."
return true -- continue with <job>
end

Expand All @@ -496,44 +505,60 @@ local jobstate = {

function update_plugin_job()

if test then
_log ("test <job> phase, parameter = " .. test)
display (nil, test)
return jobstate.Done,0
end

local title = meta.plugin.Title or '?'
local status, name, content, N, Nfiles = next_file()
if N and N == 1 then _log "starting <job> phase..." end
if status then
if status ~= 200 then
_log ("download failed, status:", status)
display (nil, title .. " failed")
--tidy up
return jobstate.Error,0
end
local f, err = io.open (downloads .. name, "wb")
if not f then
_log ("failed writing", name, "with error", err)
display (nil, title .. " failed")
return jobstate.Error,0
end
f: write (content)
f: close ()
local size = #content or 0
total = total + size
files[#files+1] = {SourceName = name}
local percent = "%s %0.0f%%"
local column = "(%d of %d) %6d %s"
_log (column:format (N, Nfiles, size, name))
display (nil, percent: format (title, 100 * N / Nfiles))
return jobstate.WaitingToStart,0 -- reschedule immediately
else
-- finish up
_log "...final <job> phase"
_log ("Total size", total)
display (nil, (title) .. " 100%")

-- copy/compress files to final destination...
local target = meta.repository.target or ludl_folder
_log ("updating icons in", icon_folder, "...")
_log ("updating device files in", target, "...")

local Nicon= 0
for file in lfs.dir (downloads) do
local source = downloads .. file
local attributes = lfs.attributes (source)
if file: match "^[^%.]" and attributes.mode == "file" then
local destination
if file:match ".+%.png$" then -- ie. *.png
Nicon = Nicon + 1
destination = icon_folder .. file
file_copy (source, destination)
else
files[#files+1] = {SourceName = file}
destination = target .. file
if Vera then
os.execute (table.concat ({"pluto-lzo c", source, destination .. ".lzo"}, ' '))
Expand All @@ -544,13 +569,20 @@ function update_plugin_job()
os.remove (source)
end
end

_log ("...", Nicon, "icon files")
_log ("...", #files, "device files")

update_InstalledPlugins2 (meta, files)
_log (meta.plugin.Title or '?', "update completed")

install_if_missing (meta)
-- display ('Reload','required')
luup.reload()
local new_install = install_if_missing (meta)
-- only perform reload if there was already a version installed
-- in order to start using the new files.
-- If a new device has been created, it will be using them, and
-- plugins often generate system reloads anyway as part of first-time setup.
if not new_install then luup.reload() end
display ('','')
return jobstate.Done,0 -- finished job
end
end
Expand All @@ -566,7 +598,13 @@ function AltAppStore_init (d)
devNo = d
_log "starting..."
display (ABOUT.NAME,'')
setVar ("Version", ABOUT.VERSION)

do -- version number
local y,m,d = ABOUT.VERSION:match "(%d+)%D+(%d+)%D+(%d+)"
local version = ("v%d.%d.%d"): format (y%2000,m,d)
setVar ("Version", version)
end

set_failure (0)
return true, "OK", ABOUT.NAME
end
Expand Down
9 changes: 7 additions & 2 deletions VeraBridge/L_VeraBridge.lua → openLuup/L_VeraBridge.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ABOUT = {
NAME = "VeraBridge",
VERSION = "2016.06.20",
VERSION = "2016.07.05",
DESCRIPTION = "VeraBridge plugin for openLuup!!",
AUTHOR = "@akbooer",
COPYRIGHT = "(c) 2013-2016 AKBooer",
Expand Down Expand Up @@ -691,7 +691,12 @@ function init (lul_device)
local Ndev, Nscn
Ndev, Nscn, BuildVersion = GetUserData ()

setVar ("Version", ABOUT.VERSION)
do -- version number
local y,m,d = ABOUT.VERSION:match "(%d+)%D+(%d+)%D+(%d+)"
local version = ("v%d.%d.%d"): format (y%2000,m,d)
setVar ("Version", version)
end

setVar ("DisplayLine1", Ndev.." devices, " .. Nscn .. " scenes", SID.altui)
setVar ("DisplayLine2", ip, SID.altui)

Expand Down
Loading

0 comments on commit ebfc6cc

Please sign in to comment.