-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapt_runner.py
More file actions
35 lines (28 loc) · 971 Bytes
/
Copy pathapt_runner.py
File metadata and controls
35 lines (28 loc) · 971 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
#!/usr/bin/python
# apt_runner.py - front-end for the apt modules
import sys
import requests
from apt_repo import Source
from repomd import Repomd
#-------------------------------------------------------------------------------
# I want stdout to be unbuffered, always
#-------------------------------------------------------------------------------
class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
#-------------------------------------------------------------------------------
# Check cmd line args
if len(sys.argv) != 2:
print(f'Usage: {sys.argv[0]} <filepath>')
exit(-1)
filepath = sys.argv[1]
srcs = Source.from_file(filepath)
for s in srcs:
print('---------------------------------------------')
print(s)