-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make all python scripts python3 compatible (#4700)
## Which problem is this PR solving? - Resolves #4673 ## Description of the changes - Adds python 3 shebang to each python script. - The same can be done in a follow up PR to jaeger-ui if this PR is accepted. ## How was this change tested? - Checked all python scripts within the jaeger project begin with a python3 shebang: ```shell $ find . -name "*.py" | grep -v site-packages | grep -v venv | grep -v jaeger-ui | xargs head -1 ``` <details> ``` ==> ./scripts/utils/ids-to-base64.py <== #!/usr/bin/env python3 ==> ./scripts/draft-release.py <== #!/usr/bin/env python3 ==> ./scripts/release-notes.py <== #!/usr/bin/env python3 ==> ./scripts/import-order-cleanup.py <== #!/usr/bin/env python3 ==> ./scripts/updateLicense.py <== #!/usr/bin/env python3 ==> ./docker-compose/monitor/otlp_exporter_example.py <== #!/usr/bin/env python3 ``` </details> - Checked all python scripts within the jaeger project are executable: ``` $ find . -name "*.py" | grep -v site-packages | grep -v venv | grep -v jaeger-ui | xargs ls -al -rwxr-xr-x 1 albertteoh staff 949 Apr 24 00:35 ./docker-compose/monitor/otlp_exporter_example.py -rwxr-xr-x 1 albertteoh staff 1561 Aug 27 06:41 ./scripts/draft-release.py -rwxr-xr-x 1 albertteoh staff 2874 Aug 26 20:44 ./scripts/import-order-cleanup.py -rwxr-xr-x 1 albertteoh staff 5095 Aug 27 06:32 ./scripts/release-notes.py -rwxr-xr-x 1 albertteoh staff 2787 Aug 26 20:44 ./scripts/updateLicense.py -rwxr-xr-x 1 albertteoh staff 848 Aug 27 06:37 ./scripts/utils/ids-to-base64.py ``` - Checked `make fmt` runs successfully. - Checked `make changelog` runs successfully. - Checked `make draft-release` runs successfully. ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits ~- [ ] I have added unit tests for the new functionality~ ~- [ ] I have run lint and test steps successfully~ - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: albertteoh <[email protected]>
- Loading branch information
1 parent
db3d1bb
commit ec5868f
Showing
9 changed files
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import re | ||
import subprocess | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
|
||
def cleanup_imports_and_return(imports): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import base64 | ||
import os | ||
import re | ||
import sys | ||
|
||
|
||
def trace_id_base64(match): | ||
id = int(match.group(1), 16) | ||
hex = '%032x' % id | ||
b64 = base64.b64encode(hex.decode('hex')) | ||
return '"traceId": "%s"' % b64 | ||
|
||
|
||
def span_id_base64(match): | ||
id = int(match.group(1), 16) | ||
hex = '%016x' % id | ||
b64 = base64.b64encode(hex.decode('hex')) | ||
return '"spanId": "%s"' % b64 | ||
return f'"spanId": "{b64}"' | ||
|
||
|
||
for file in sys.argv[1:]: | ||
print file | ||
backup = '%s.bak' % file | ||
print(file) | ||
backup = f'{file}.bak' | ||
with open(file, 'r') as fin: | ||
with open(backup, 'w') as fout: | ||
for line in fin: | ||
# line = line[:-1] # remove \n | ||
line = re.sub(r'"traceId": "(.+)"', trace_id_base64, line) | ||
line = re.sub(r'"spanId": "(.+)"', span_id_base64, line) | ||
# print(line) | ||
fout.write(line) | ||
os.remove(file) | ||
os.rename(backup, file) |