Skip to content

Commit

Permalink
First packaged version of SciDB hquery released to git and cabal.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdgabriel committed Jul 6, 2019
0 parents commit 3279a58
Show file tree
Hide file tree
Showing 13 changed files with 3,809 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Revision history for scidb-hquery

## 2.8.0.429 -- 2019-07-06

* First packaged version of SciDB hquery released to git and cabal.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Distribution.PackageDescription (BuildInfo)
import Distribution.Simple (UserHooks(..),defaultMainWithHooks,simpleUserHooks)
import Distribution.Simple.BuildPaths (autogenComponentModulesDir)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..),ComponentLocalBuildInfo)
import Distribution.Simple.PreProcess (PreProcessor(..),knownSuffixHandlers,mkSimplePreProcessor)
import Distribution.Simple.Program (Program(..),findProgramVersion,runDbProgram,simpleProgram)
import Distribution.Simple.Utils (info)
import System.FilePath (takeBaseName,takeDirectory)

main :: IO ()
main =
defaultMainWithHooks simpleUserHooks{hookedPreProcessors = ("cf",ppBnfc):knownSuffixHandlers}

ppBnfc :: BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor
ppBnfc _ lbi clbi =
PreProcessor {platformIndependent = True
,runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity ->
do info verbosity ("Running "++programName bnfcProgram
++" --outputdir="++autogenDir
++" --haskell " ++ inFile
)
runDbProgram verbosity bnfcProgram (withPrograms lbi)
["--outputdir="++autogenDir, "--haskell", inFile]
info verbosity ("Creating "++programName bnfcProgram++" output file '"++outFile++"'"
++" from input file '"++inFile++"'")
outFile `makeFrom` inFile
}
where autogenDir = autogenComponentModulesDir lbi clbi

bnfcProgram :: Program
bnfcProgram = (simpleProgram "bnfc") {
-- Invoking "bnfc --version" gives a string like "2.8.2"
programFindVersion = findProgramVersion "--version" id
}

makeFrom :: String -> String -> IO ()
makeFrom outFile inFile = do inFileStr <- readFile inFile
writeFile outFile (outFileStrFrom inFileStr)
where outFileStrFrom inFileStr =
"{- |\n"
++"This is the SciDB AFL BNFC file:\n"
++"\n"
++quote inFileStr++"\n"
++"-}\n"
++"\n"
++"module "++takeBaseName inFile++" where\n"
++"\n"
++"-- | BNFC configuration file as a string, for the purposes of documentation.\n"
++"bnfcFile :: String\n"
++"bnfcFile = "++show inFileStr++"\n"
quote inFileStr = unlines $ fmap ("> "++) $ lines inFileStr

133 changes: 133 additions & 0 deletions scidb-hquery.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
cabal-version: 2.4
name: scidb-hquery
version: 2.8.0.429
license: GPL-3.0-only
license-file: LICENSE
copyright: All rights reserved 2014-19(c).
maintainer: marcus@gabriel.name
author: Marcus D. Gabriel
homepage:
bug-reports:
synopsis: Haskell query for SciDB via shim
description:
The command hquery with no operands and no options will begin an
interacitve session with a SciDB server using SciDB's shim
protocol at http://localhost:8080. See hquery -m for a manual
page and http://www.paradigm4.com/ for more infomation.
category: Database
build-type: Custom
extra-source-files:
CHANGELOG.md
src/SciDbAFL.cf

custom-setup
setup-depends: base >=4.12.0.0 && <4.13,
Cabal >=2.4.1.0 && <2.5,
filepath >=1.4.2.1 && <1.5

library
exposed-modules:
Environment
SciDbAFL
ErrM
HQuery
License
Manual
Utils
UtilsUnsafe
build-tool-depends: BNFC:bnfc >=2.8.2, alex:alex >=3.2.4,
happy:happy >=1.19.9
hs-source-dirs: src
other-modules:
AbsSciDbAFL
Interpreter
LexSciDbAFL
ParSciDbAFL
PrintSciDbAFL
autogen-modules:
SciDbAFL
AbsSciDbAFL
ErrM
LexSciDbAFL
ParSciDbAFL
PrintSciDbAFL
default-language: Haskell2010
build-depends:
base >=4.12.0.0 && <4.13,
HTTP >=4000.3.14 && <4000.4,
array >=0.5.3.0 && <0.6,
bytestring >=0.10.8.2 && <0.11,
connection >=0.3.0 && <0.4,
cryptonite ==0.26.*,
data-default-class >=0.1.2.0 && <0.2,
exceptions >=0.10.2 && <0.11,
haskeline >=0.7.4.3 && <0.8,
hostname-validate >=1.0.0 && <1.1,
http-client >=0.6.4 && <0.7,
http-client-tls >=0.3.5.3 && <0.4,
http-conduit >=2.3.7.1 && <2.4,
http-types >=0.12.3 && <0.13,
memory >=0.14.18 && <0.15,
mtl >=2.2.2 && <2.3,
network >=3.1.0.1 && <3.2,
process >=1.6.5.0 && <1.7,
regex >=1.0.0.0 && <1.1,
safe >=0.3.17 && <0.4,
split >=0.2.3.3 && <0.3,
terminal-size >=0.3.2.1 && <0.4,
text >=1.2.3.1 && <1.3,
tls >=1.5.0 && <1.6,
x509-store >=1.6.7 && <1.7

executable hquery
main-is: Main.hs
hs-source-dirs: src
other-modules:
SciDbAFL
AbsSciDbAFL
Environment
ErrM
HQuery
LexSciDbAFL
License
Manual
ParSciDbAFL
PrintSciDbAFL
Utils
UtilsUnsafe
autogen-modules:
SciDbAFL
AbsSciDbAFL
ErrM
LexSciDbAFL
ParSciDbAFL
PrintSciDbAFL
default-language: Haskell2010
build-depends:
base >=4.12.0.0 && <4.13,
HTTP >=4000.3.14 && <4000.4,
array >=0.5.3.0 && <0.6,
bytestring >=0.10.8.2 && <0.11,
connection >=0.3.0 && <0.4,
cryptonite ==0.26.*,
data-default-class >=0.1.2.0 && <0.2,
directory >=1.3.3.0 && <1.4,
exceptions >=0.10.2 && <0.11,
filepath >=1.4.2.1 && <1.5,
haskeline >=0.7.4.3 && <0.8,
hostname-validate >=1.0.0 && <1.1,
http-client >=0.6.4 && <0.7,
http-client-tls >=0.3.5.3 && <0.4,
http-conduit >=2.3.7.1 && <2.4,
http-types >=0.12.3 && <0.13,
memory >=0.14.18 && <0.15,
mtl >=2.2.2 && <2.3,
network >=3.1.0.1 && <3.2,
process >=1.6.5.0 && <1.7,
regex >=1.0.0.0 && <1.1,
safe >=0.3.17 && <0.4,
split >=0.2.3.3 && <0.3,
terminal-size >=0.3.2.1 && <0.4,
text >=1.2.3.1 && <1.3,
tls >=1.5.0 && <1.6,
x509-store >=1.6.7 && <1.7
97 changes: 97 additions & 0 deletions src/Environment.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

module Environment(Environment(..), defaultEnv, maybePort,Verbosity(..)) where

import Data.Maybe (fromMaybe)
import Network.HTTP.Types.Header (RequestHeaders)

data Verbosity = Verbose0 -- ^ Verbosity level 0, no information to stderr
| VerboseDef -- ^ Default verbosity, only relevant HTTP exceptions to stderr
| Verbose1 -- ^ Verbosity level 1, additional HTTP exceptions and trace information to stderr
| Verbose2 -- ^ Verbosity level 2, additional URL information to stderr
deriving (Show,Eq,Ord)

{- | Given an 'Environment', return a port or a default port.
-}
maybePort :: Environment -> String
maybePort e = fromMaybe port' (port e)
where port' = (if protocol e == "https" then secPort else defPort) e

-- Section: Environment
{- |
The 'Environment' contains the command name, operands, defaults, and the
result of every option amongst other entries. It is set by 'main' and
otherwise to be used as a read-only 'Environment'.
-}
data Environment =
Env { command :: String -- ^ Program name
, pwd :: String -- ^ Present Working Directory (PWD)
, home :: String -- ^ Home directory or /tmp
, history :: String -- ^ History file for command
, protocol :: String -- ^ Protoocl http or https
, certStore :: String -- ^ Load and use certificate store
, insecure :: Bool -- ^ Use "insecure" SSL/TLS, i.e., no cert validation
, scidbAuth :: Bool -- ^ Use SciDB authentication
, digestAuth :: Bool -- ^ Use basic digest access authentication
, digestHeaders::RequestHeaders-- ^ Digest request headers or nothing for the GET method
, defFetch :: Maybe Bool -- ^ True fetch lines, false do not fetch lines
, defFormat :: String -- ^ Format dcsv, csv, csv+, etc.
, defNumber :: String -- ^ Number of lines to fetch, n=0 for all; default for bad number
, defReadingLines::Maybe Bool -- ^ True to read lines from shim otheriwise read bytes
, defPrefix :: String -- ^ Prefix to execute before a query by shim
, host :: String -- ^ Hostname or IP address
, port :: Maybe String -- ^ Port number
, defPort :: String -- ^ Default insecure or unencypted port number
, secPort :: String -- ^ Default secure or encypted port number
, username :: String -- ^ Username
, password :: String -- ^ Password for username
, operands :: [String] -- ^ List of queries
, file :: String -- ^ File of queries
, help :: Bool -- ^ @-h@, display help summary
, license :: Bool -- ^ @-l@, display license terms
, manual :: Bool -- ^ @-m@, display internal man page
, version :: Bool -- ^ @-v@, display version
, synopsis :: Bool -- ^ @-y@, display manual synopsis
, verbose :: Verbosity -- ^ @-V|-V[012]@, display verbose information to stderr
, sciDbVersion:: String -- ^ Store SciDB version, e.g., 18.1.0
, versionSciDb:: Bool -- ^ True to display SciDB version via shim
} deriving Show

-- The default Environment
{- |
The defualt values, otherwise updated from the flags supplied by the
command line options. The default program name is 'hquery'.
-}
defaultEnv :: Environment
defaultEnv =
Env { command = "hquery" -- Default program name
, pwd = "" -- No PWD by default
, home = "/tmp" -- /tmp if $HOME does not exist
, history = "" -- History file for command
, protocol = "http" -- No authentication needed for http
, certStore = "" -- Load and use certificate store
, insecure = False -- Use "insecure" SSL/TLS, i.e., no cert validation
, scidbAuth = False -- Use SciDB authentication
, digestAuth = False -- Use basic digest access authentication
, digestHeaders=[] -- Digest request headers or nothing for the GET method
, defFetch = Just True -- True fetch lines, false do not fetch lines
, defFormat = "dcsv" -- Format dcsv, csv, csv+, etc.
, defNumber = "23" -- Default 23 lines, default for bad number
, defReadingLines=Just True -- True to read lines from shim otheriwise read bytes
, defPrefix = "" -- Prefix to execute before a query by shim
, host = "localhost" -- Use local shim connection
, port = Nothing -- Nothing for default port number not needing authentication
, defPort = "8080" -- Default port number not needing authentication
, secPort = "8083" -- Default port number needing authentication
, username = "" -- Username needed for -d or -s option
, password = "" -- Password needed for -d or -s option
, operands = [] -- No operands by default, i.e., interactive mode
, file = "" -- No file of queries by default
, help = False -- False or off by default
, license = False -- False or off by default
, manual = False -- False or off by default
, synopsis = False -- False or off by default
, version = False -- False or off by default
, verbose = VerboseDef -- Default verbosity
, sciDbVersion= "" -- Store SciDB version, e.g., 18.1.0
, versionSciDb= False -- True to display SciDB version via shim
}
Loading

0 comments on commit 3279a58

Please sign in to comment.