You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/06/15 22:26:25 UTC

ambari git commit: AMBARI-11936: Remove gzip dependency in Slider view for Windows (jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk e518ac33a -> 780dea082


AMBARI-11936: Remove gzip dependency in Slider view for Windows (jluniya)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/780dea08
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/780dea08
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/780dea08

Branch: refs/heads/trunk
Commit: 780dea082e715398adb43fd0359efa2c5c7b9213
Parents: e518ac3
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Mon Jun 15 13:26:20 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Mon Jun 15 13:26:20 2015 -0700

----------------------------------------------------------------------
 contrib/views/slider/gzip-content.cmd | 17 +++++++
 contrib/views/slider/gzip-content.ps1 | 81 ++++++++++++++++++++++++++++++
 contrib/views/slider/pom.xml          |  2 +-
 3 files changed, 99 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/780dea08/contrib/views/slider/gzip-content.cmd
----------------------------------------------------------------------
diff --git a/contrib/views/slider/gzip-content.cmd b/contrib/views/slider/gzip-content.cmd
new file mode 100644
index 0000000..21838f8
--- /dev/null
+++ b/contrib/views/slider/gzip-content.cmd
@@ -0,0 +1,17 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+powershell -File %~dpn0.ps1 %* < NUL
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/780dea08/contrib/views/slider/gzip-content.ps1
----------------------------------------------------------------------
diff --git a/contrib/views/slider/gzip-content.ps1 b/contrib/views/slider/gzip-content.ps1
new file mode 100644
index 0000000..a6042a1
--- /dev/null
+++ b/contrib/views/slider/gzip-content.ps1
@@ -0,0 +1,81 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+Function Gzip-File{
+   Param(
+        $inFile,
+        $outFile = ($inFile + ".gz"),
+        $force = $false
+        )
+  if(-not (Test-Path $inFile)) {
+    Write-Host "$inFile does not exist"
+    return $false
+  }
+  if((Test-Path $outFile)) {
+    if(-not $force) {
+      Write-Host "$outFile already exists"
+      return $true
+    } else {
+      Remove-Item $outFile
+    }
+  }
+  $inputStream = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read)
+  $outputStream = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None)
+  $gzipStream = New-Object System.IO.Compression.GzipStream $outputStream, ([IO.Compression.CompressionMode]::Compress)
+
+  $buffer = New-Object byte[](1024)
+  while($true){
+    $read = $inputStream.Read($buffer, 0, 1024)
+    if ($read -le 0){break}
+    $gzipStream.Write($buffer, 0, $read)
+  }
+  $gzipStream.Close()
+  $outputStream.Close()
+  $inputStream.Close()
+  Remove-Item $inFile
+  return $true
+}
+
+$errorFound = $false
+$files = @()
+$force = $false
+ForEach ($arg in $args) {
+  if($arg -eq "-f" -or $arg -eq "--force") {
+    $force = $true
+    continue
+  }
+  $files += $arg
+}
+
+ForEach ($file in $files) {
+  $input = $file
+  $output = $file + ".gz";
+  Write-Host "Running: Gzip-File $input $output $force"
+  $success = Gzip-File $input $output $force
+  if(-not $success) {
+    $errorFound = $true
+  }
+}
+
+if ($errorFound) {
+  throw "Failed to gzip all files!"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/780dea08/contrib/views/slider/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/slider/pom.xml b/contrib/views/slider/pom.xml
index 5cf06ca..5f5df53 100644
--- a/contrib/views/slider/pom.xml
+++ b/contrib/views/slider/pom.xml
@@ -394,7 +394,7 @@
         <executable.python>python</executable.python>
         <executable.brunch>cmd</executable.brunch>
         <args.brunch>/C brunch</args.brunch>
-        <executable.gzip>gzip</executable.gzip>
+        <executable.gzip>gzip-content.cmd</executable.gzip>
         <executable.mkdir>cmd</executable.mkdir>
         <args.mkdir>/C mkdir</args.mkdir>
         <executable.npm>cmd</executable.npm>