-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from gm3dmo/v70
Adding script titles
- Loading branch information
Showing
10 changed files
with
86 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from cmp.models import SoldierImprisonment | ||
|
||
def run(): | ||
Imprisonments = SoldierImprisonment.objects.all() | ||
Imprisonments.delete() |
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
def run(): | ||
|
||
import sys | ||
import urllib3 | ||
import csv | ||
from cmp.models import SoldierImprisonment | ||
|
||
print() | ||
title = sys.argv[2] | ||
print(f"""\033[4;33m{title}\033[0m""") | ||
print("-" * len(title)) | ||
|
||
ref_data_url = "https://raw.githubusercontent.com/gm3dmo/old-cmp/main/data/soldier-imprisonment.csv" | ||
http = urllib3.PoolManager() | ||
r = http.request('GET', ref_data_url) | ||
print(r.status) | ||
# load the response into a csv dictionary reader | ||
reader = csv.DictReader(r.data.decode('utf-8').splitlines()) | ||
# breakpoint() | ||
print(reader) | ||
# print(reader.fieldnames) | ||
# id,soldier_id,company_id,powNumber,powCamp_id,dateFrom,dateTo,notes | ||
for row in reader: | ||
print(f"""SoldierImprisonment: {row['id']} {row['soldier_id']} """) | ||
try: | ||
SoldierImprisonment.objects.create( | ||
id = row['id'], | ||
soldier_id = row['soldier_id'], | ||
legacy_company = row['company_id'], | ||
pow_number = row['powNumber'], | ||
pow_camp_id = row['powCamp_id'], | ||
legacy_date_from = row['dateFrom'], | ||
legacy_date_to = row['dateTo'], | ||
notes = row['notes'] | ||
) | ||
except Exception as e: | ||
print("Error with: " + row['id']) | ||
|
||
raise e |
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