Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Companion App Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andy B-S
Companion App Android
Commits
0318c9ab
Commit
0318c9ab
authored
Aug 18, 2019
by
Anon
Browse files
Options
Downloads
Patches
Plain Diff
Set up card10 folder structure and launcher script.
parent
2fc8dac7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/de/ccc/events/badge/card10/hatchery/AppDetailFragment.kt
+24
-6
24 additions, 6 deletions
.../de/ccc/events/badge/card10/hatchery/AppDetailFragment.kt
with
24 additions
and
6 deletions
app/src/main/java/de/ccc/events/badge/card10/hatchery/AppDetailFragment.kt
+
24
−
6
View file @
0318c9ab
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
package
de.ccc.events.badge.card10.hatchery
package
de.ccc.events.badge.card10.hatchery
import
android.content.DialogInterface
import
android.os.AsyncTask
import
android.os.AsyncTask
import
android.os.Bundle
import
android.os.Bundle
import
android.util.Log
import
android.util.Log
...
@@ -34,7 +33,6 @@ import androidx.fragment.app.Fragment
...
@@ -34,7 +33,6 @@ import androidx.fragment.app.Fragment
import
de.ccc.events.badge.card10.R
import
de.ccc.events.badge.card10.R
import
de.ccc.events.badge.card10.common.LoadingDialog
import
de.ccc.events.badge.card10.common.LoadingDialog
import
kotlinx.android.synthetic.main.app_detail_fragment.*
import
kotlinx.android.synthetic.main.app_detail_fragment.*
import
org.apache.commons.compress.archivers.tar.TarArchiveEntry
import
org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import
org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import
org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream
import
org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream
import
java.io.File
import
java.io.File
...
@@ -90,6 +88,7 @@ class AppDetailFragment : Fragment() {
...
@@ -90,6 +88,7 @@ class AppDetailFragment : Fragment() {
return
try
{
return
try
{
cacheDir
.
deleteRecursively
()
cacheDir
.
deleteRecursively
()
cacheDir
.
mkdir
()
cacheDir
.
mkdir
()
val
appDir
=
File
(
cacheDir
.
absolutePath
+
"/apps"
).
mkdirs
()
val
inputStream
=
HatcheryClient
().
openDownloadStream
(
app
)
val
inputStream
=
HatcheryClient
().
openDownloadStream
(
app
)
val
file
=
File
.
createTempFile
(
app
.
slug
,
".tar.gz"
,
cacheDir
)
val
file
=
File
.
createTempFile
(
app
.
slug
,
".tar.gz"
,
cacheDir
)
...
@@ -97,7 +96,7 @@ class AppDetailFragment : Fragment() {
...
@@ -97,7 +96,7 @@ class AppDetailFragment : Fragment() {
inputStream
.
copyTo
(
outputStream
)
inputStream
.
copyTo
(
outputStream
)
val
unpacked
Files
=
mutableListOf
<
String
>()
val
app
Files
=
mutableListOf
<
String
>()
val
tarStream
=
TarArchiveInputStream
(
GzipCompressorInputStream
(
file
.
inputStream
()))
val
tarStream
=
TarArchiveInputStream
(
GzipCompressorInputStream
(
file
.
inputStream
()))
while
(
true
)
{
while
(
true
)
{
val
entry
=
tarStream
.
nextTarEntry
?:
break
val
entry
=
tarStream
.
nextTarEntry
?:
break
...
@@ -106,15 +105,18 @@ class AppDetailFragment : Fragment() {
...
@@ -106,15 +105,18 @@ class AppDetailFragment : Fragment() {
}
}
// TODO: A bit hacky. Maybe there is a better way?
// TODO: A bit hacky. Maybe there is a better way?
val
targetFile
=
File
(
cacheDir
,
entry
.
name
)
val
targetFile
=
File
(
cacheDir
,
"apps/${
entry.name
}"
)
targetFile
.
parentFile
?.
mkdirs
()
targetFile
.
parentFile
?.
mkdirs
()
targetFile
.
createNewFile
()
targetFile
.
createNewFile
()
Log
.
d
(
TAG
,
"Extracting ${entry.name} to ${targetFile.absolutePath}"
)
Log
.
d
(
TAG
,
"Extracting ${entry.name} to ${targetFile.absolutePath}"
)
tarStream
.
copyTo
(
targetFile
.
outputStream
())
tarStream
.
copyTo
(
targetFile
.
outputStream
())
unpacked
Files
.
add
(
entry
.
name
)
app
Files
.
add
(
"apps/${
entry.name
}"
)
}
}
unpackedFiles
val
launcher
=
createLauncher
(
app
.
slug
,
cacheDir
)
appFiles
.
add
(
launcher
)
appFiles
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
null
null
}
}
...
@@ -129,5 +131,21 @@ class AppDetailFragment : Fragment() {
...
@@ -129,5 +131,21 @@ class AppDetailFragment : Fragment() {
loadingDialog
.
dismiss
()
loadingDialog
.
dismiss
()
}
}
fun
createLauncher
(
slug
:
String
,
cacheDir
:
File
):
String
{
val
fileName
=
"$slug.py"
val
file
=
File
(
cacheDir
,
fileName
)
file
.
createNewFile
()
val
src
=
"""
# Launcher script for $slug
import os
os.exec("apps/$slug/__init__.py")
"""
.
trimIndent
()
file
.
writeText
(
src
)
return
fileName
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment