Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python mérés
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blint-public
6. félév
Infokomm labor
python mérés
Commits
d9aadb2f
Verified
Commit
d9aadb2f
authored
3 years ago
by
Réthelyi Bálint
Browse files
Options
Downloads
Patches
Plain Diff
add ci
parent
fadebdfa
No related branches found
No related tags found
No related merge requests found
Pipeline
#20278
failed
3 years ago
Stage: build
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+12
-0
12 additions, 0 deletions
.gitlab-ci.yml
README.md
+15
-0
15 additions, 0 deletions
README.md
metadata.yaml
+3
-0
3 additions, 0 deletions
metadata.yaml
solutions/1_feladat.md
+99
-3
99 additions, 3 deletions
solutions/1_feladat.md
with
129 additions
and
3 deletions
.gitlab-ci.yml
0 → 100644
+
12
−
0
View file @
d9aadb2f
image
:
pandoc/latex
stages
:
-
build
generate pdf
:
stage
:
build
script
:
-
pandoc -pdf-engine=lualatex --metadata-file=metadata.yml solutions/* -o solutions.pdf
artifacts
:
paths
:
-
solutions.pdf
\ No newline at end of file
This diff is collapsed.
Click to expand it.
README.md
+
15
−
0
View file @
d9aadb2f
...
@@ -113,3 +113,18 @@ vissza egy üres tuple-lal!
...
@@ -113,3 +113,18 @@ vissza egy üres tuple-lal!
-
Teszteljük a most megírt modulunkat interaktív módon (indítsunk egy Python interpretert, importáljuk be és hívjuk meg
-
Teszteljük a most megírt modulunkat interaktív módon (indítsunk egy Python interpretert, importáljuk be és hívjuk meg
a függvényt) és nézzük meg a modul/függvény dokumentációkat is a
`help()`
függvénnyel!
a függvényt) és nézzük meg a modul/függvény dokumentációkat is a
`help()`
függvénnyel!
## 1.d Feladat - Futtatható DNS szkript
**Feladat:**
Tegyük futtathatóvá az elkészült modult!
-
[
dns_tool2.py.txt
](
https://qosip.tmit.bme.hu/foswiki/pub/Meres/PythonFeladatok/dns_tool2.py.txt
)
: Skeleton szkript az
1.
feladathoz - Nevezzük át a fájlt!
-
A szkriptet ne hagyományos (és mondhatni elavult) shebang sorral definiáljuk, hanem a rugalmasabb és esetünkben fontos
`env`
paranccsal (Lásd az 1. Feladat bevezetőjét)!
-
Figyeljünk arra, hogy a modul importálható maradjon (ellenőrizzük a
`__name__`
paramétert)!
-
Futtatáshoz ne felejtsünk el futtatási jogot adni a szkriptnek (
`$ chmod a+x dns_tool2.py, futtatás: ./dns_tool2.py`
)!
-
Modul futtatásakor a DNS nevet interaktív módon, a konzolon keresztül kérjük be a megfelelő beépített függvénnyel
(
`input()`
)!
This diff is collapsed.
Click to expand it.
metadata.yaml
0 → 100644
+
3
−
0
View file @
d9aadb2f
geometry
:
margin=2cm
lang
:
hu-HU
output
:
pdf_document
\ No newline at end of file
This diff is collapsed.
Click to expand it.
solutions/1_feladat.md
+
99
−
3
View file @
d9aadb2f
...
@@ -47,6 +47,30 @@ Host alt2.aspmx.l.google.com. has preference 30
...
@@ -47,6 +47,30 @@ Host alt2.aspmx.l.google.com. has preference 30
**Feladat:**
Hosszabb kódok esetén az interaktív interpreter használata körülményes. Írjunk Python modult
`dns_tool.py`
**Feladat:**
Hosszabb kódok esetén az interaktív interpreter használata körülményes. Írjunk Python modult
`dns_tool.py`
néven az előző feladatban megvalósított funkcióhoz!
néven az előző feladatban megvalósított funkcióhoz!
A forráskód:
```
python3
from dns.resolver import query
from dns.exception import DNSException
# input: dns name and optional the type of the record and return all the answered data in a list or in
# case of exception an empty list
def get_mx(dns_name, type="MX"):
try:
answers = query(dns_name, type)
except DNSException:
return []
ret = []
for a in answers:
element = (str(a.preference), str(a.exchange))
ret.append(element)
return ret
```
Futtatás:
```
bash
```
bash
$
python3
$
python3
>>>
import dns_tool
>>>
import dns_tool
...
@@ -55,8 +79,8 @@ help> dns_tool.get_mx
...
@@ -55,8 +79,8 @@ help> dns_tool.get_mx
Help on
function
get_mx
in
dns_tool:
Help on
function
get_mx
in
dns_tool:
dns_tool.get_mx
=
get_mx
(
dns_name,
type
=
'MX'
)
dns_tool.get_mx
=
get_mx
(
dns_name,
type
=
'MX'
)
# input: dns name and optional the type of the record and return all the answered data in a list
or in case of exception
# input: dns name and optional the type of the record and return all the answered data in a list
# an empty list
#
or in case of exception
an empty list
>>>
list
=
dns_tool.get_mx
(
'google.com'
)
>>>
list
=
dns_tool.get_mx
(
'google.com'
)
>>>
for
e
in
list:
>>>
for
e
in
list:
... print
(
e
)
... print
(
e
)
...
@@ -73,3 +97,75 @@ dns_tool.get_mx = get_mx(dns_name, type='MX')
...
@@ -73,3 +97,75 @@ dns_tool.get_mx = get_mx(dns_name, type='MX')
...
...
>>>
>>>
```
```
## 1.d Feladat - Futtatható DNS szkript
**Feladat:**
Tegyük futtathatóvá az elkészült modult!
A forráskód:
```
python3
#!/usr/bin/env python3
from dns.resolver import query
from dns.exception import DNSException
# input: dns name and optional the type of the record and return all the answered data in a list or in
# case of exception an empty list
def get_mx(dns_name, type="MX"):
try:
answers = query(dns_name, type)
except DNSException:
return []
ret = []
for a in answers:
element = (str(a.preference), str(a.exchange))
ret.append(element)
return ret
if __name__ == "__main__":
inp = input("Add meg a lekérdezendő domain-t, valamint ha szeretnéd specifikálni, a rekord típusát is szóközzel "
"elválasztva (az alapértelmezett rekord típus az MX): ")
inp = inp.split(" ")
if len(inp) >= 2:
list = get_mx(inp[0], inp[1])
for e in list:
print(e)
else:
list = get_mx(inp[0])
for e in list:
print(e)
```
Futtatás:
```
bash
$
chmod
+x dns_tool2.py
$
./dns_tool2.py
Add meg a lekérdezendő domain-t, valamint ha szeretnéd specifikálni, a rekord típusát is szóközzel
elválasztva
(
az alapértelmezett rekord típus az MX
)
: google.com MX ./dns_tool2.py:11: DeprecationWarning:
please use dns.resolver.resolve
()
instead
answers
=
query
(
dns_name,
type
)
(
'10'
,
'aspmx.l.google.com.'
)
(
'20'
,
'alt1.aspmx.l.google.com.'
)
(
'50'
,
'alt4.aspmx.l.google.com.'
)
(
'40'
,
'alt3.aspmx.l.google.com.'
)
(
'30'
,
'alt2.aspmx.l.google.com.'
)
```
A forráskód:
```
python3
```
Futtatás:
```
bash
```
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