Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fortune-cow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Moser
fortune-cow
Commits
87a5f4f3
Commit
87a5f4f3
authored
1 year ago
by
Jakob Moser
Browse files
Options
Downloads
Patches
Plain Diff
Add fortune cow
parent
7b3047fa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fortune_cow.py
+28
-0
28 additions, 0 deletions
fortune_cow.py
with
28 additions
and
0 deletions
fortune_cow.py
0 → 100644
+
28
−
0
View file @
87a5f4f3
#!/usr/bin/env python3
import
subprocess
from
typing
import
Optional
def
_run
(
executable
:
str
,
argument
:
Optional
[
str
]
=
None
)
->
str
:
cmd
=
[
executable
,
argument
]
if
argument
else
[
executable
]
result
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
text
=
True
,
check
=
True
)
return
result
.
stdout
.
strip
()
def
get_fortune
()
->
str
:
return
_run
(
"
/usr/games/fortune
"
)
def
get_cowsay
(
text
:
str
)
->
str
:
return
_run
(
"
/usr/games/cowsay
"
,
text
)
if
__name__
==
"
__main__
"
:
fortune_text
=
get_fortune
()
cow_saying_fortune
=
get_cowsay
(
fortune_text
)
print
()
print
(
"
And the cow of the day says:
"
)
print
(
cow_saying_fortune
)
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