-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainer_demo.py
More file actions
38 lines (29 loc) · 761 Bytes
/
container_demo.py
File metadata and controls
38 lines (29 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
import sys
import os
# traditional "Hello, Hello!" speach.
print ("Hello, Hello!")
# check for environment variable and print it
# maybe set environment varialbe then demonstrate it only chaning in
# container
print( "SING_DEMO environment varialbe is set to: %s" % os.getenv('SING_DEMO'))
# read stdin
if not sys.stdin.isatty():
print("begin STDIN")
for line in sys.stdin:
print(line.rstrip("\n\r"))
print("end STDIN")
else:
print("no STDIN")
# open a file?
try:
filename = sys.argv[1]
except:
filename = "/etc/issue"
print("Reading from file: "+filename)
try:
file = open(filename)
for fline in file:
print (fline.rstrip("\n\r"))
except:
print("can't open file: "+filename)