Skip to content

Commit

Permalink
rm whitout html and add Mars
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdyaea committed Dec 14, 2019
1 parent 6bb08d1 commit 9f21d06
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 810 deletions.
343 changes: 340 additions & 3 deletions HTMLSolarSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __init__(self):
self.VenusResult
self.VenusPerihelion
self.NewVenusPerihelion
self.MarsResult
self.MarsPerihelion
self.NewMarsPerihelion


Percentage.current_year = date.today().year
Expand Down Expand Up @@ -353,7 +356,7 @@ def Moon(): # d0 = first perihelion , d1 = today , d2 = next perihelion
Percentage.current_year, Percentage.thisMonth, Percentage.today
)
if (
d0 <= d1 - timedelta(days=30) and d0 >= d1
d0 >= d1 - timedelta(days=30) and d0 <= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewMoonPerihelion = d0

Expand Down Expand Up @@ -649,7 +652,7 @@ def Mercury(): # d0 = first perihelaperihelion
)
d1 = d1 + timedelta(days=1)
if (
d0 <= d1 - timedelta(days=90) and d0 >= d1
d0 >= d1 - timedelta(days=90) and d0 <= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewMercuryPerihelion = d0

Expand Down Expand Up @@ -958,7 +961,7 @@ def Venus(): # d0 = first perihelion , d1 = today , d2 = next perihelion
)
d1 = d1 + timedelta(days=1)
if (
d0 <= d1 - timedelta(days=250) and d0 >= d1
d0 >= d1 - timedelta(days=700) and d0 <= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewVenusPerihelion = d0

Expand Down Expand Up @@ -1046,6 +1049,335 @@ def Venus(): # d0 = first perihelion , d1 = today , d2 = next perihelion
Percentage.barrVenusHTML = (
"Percent of this year : " + (barre) + ("<br />")
)

def Mars(): # d0 = first perihelion , d1 = today , d2 = next perihelion

# Rotation year before this year
years_ago_full = datetime.now() - timedelta(
days=1 * 365
) # adapt to the number of years
years_ago_full = str(years_ago_full)
years_ago = years_ago_full[:4]
years_ago = int(years_ago) # result

# Next rotation year
years_after_full = datetime.now() + timedelta(
days=1 * 365
) # adapt to the number of years
years_after_full = str(years_after_full)
years_after = years_after_full[:4]
years_after = int(years_after) # result

with open("/var/www/html/Orbit.json", "r") as O:
orbit = json.load(O)
try:
thisYear = orbit["Mars"][str(Percentage.current_year)] # This year
except:
thisYear = orbit["Mars"][str(Percentage.current_year-1)]
years_ago = orbit["Mars"][str(years_ago)][-1]
years_after = orbit["Mars"][str(years_after)][0]
try:
for i in thisYear:
d0Year = i[:4]
d0Year = int(d0Year)
d0Month = i[5:7]
d0Month = int(d0Month)
d0Day = i[8:10]
d0Day = int(d0Day)
d0 = date(d0Year, d0Month, d0Day)
d1 = date(
Percentage.current_year, Percentage.thisMonth, Percentage.today
)
d1 = d1 + timedelta(days=1)
if (
d0 >= d1 - timedelta(days=700) and d0 <= d1
): # i is bigger or equal today - 30 days and smaller or equal today : First day of rotation
Percentage.MarsPerihelion = d0

for i in thisYear:
d0Year = i[:4]
d0Year = int(d0Year)
d0Month = i[5:7]
d0Month = int(d0Month)
d0Day = i[8:10]
d0Day = int(d0Day)
d0 = date(d0Year, d0Month, d0Day)
d1 = date(
Percentage.current_year, Percentage.thisMonth, Percentage.today
)
d1 = d1 + timedelta(days=1)
if (
d0 <= d1 + timedelta(days=700) and d0 >= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewMarsPerihelion = d0
d1 = date(
Percentage.current_year, Percentage.thisMonth, Percentage.today
)
d3 = Percentage.NewMarsPerihelion - Percentage.MarsPerihelion
d3 = str(d3)
d3 = d3[:3]
d3 = int(d3)
d3 = d3 + 1
ValuePercent = d3 / 100
delta = d1 - Percentage.MarsPerihelion
new = re.sub("[^0-9]", "", str(delta))
new = str(new)
new = new[:3]
new = int(new)

Percentage.MarsResult = new / ValuePercent
Percentage.MarsResult = round(Percentage.MarsResult, 2)

# Add graph progress #####

print("Planet : Mars")
print(("Day of the year : ") + str("Day ") + str(new))
print(("Year progress : ") + str(Percentage.MarsResult) + str("%"))

percent = Percentage.MarsResult
barre = (
"["
+ "#" * int((50 / 100) * percent)
+ "-" * int((50 / 100) * (100 - percent))
+ "]"
)
print("Percent of this year : " + (barre))
print("\n")
Percentage.MarsHTML = (
("Planet : Mars")
+ ("<br />")
+ str(("Day of the year : ") + str("Day ") + str(new))
+ ("<br />")
+ str(
("Year progress : ")
+ str(Percentage.MarsResult)
+ str("%")
+ ("<br />")
)
)
percent = Percentage.MarsResult
barre = (
"["
+ "#" * int((50 / 100) * percent)
+ "_" * int((50 / 100) * (100 - percent))
+ "]"
)
Percentage.barrMars = (
"Percent of this year : " + (barre) + str("\n")
)
Percentage.barrMarsHTML = (
"Percent of this year : " + (barre) + ("<br />")
)
except:
try:
for i in thisYear:
d0Year = i[:4]
d0Year = int(d0Year)
d0Month = i[5:7]
d0Month = int(d0Month)
d0Day = i[8:10]
d0Day = int(d0Day)
d0 = date(d0Year, d0Month, d0Day)
d1 = date(
Percentage.current_year, Percentage.thisMonth, Percentage.today
)
if (
d0 >= d1 - timedelta(days=700) and d0 <= d1
): # i is bigger or equal today - 30 days and smaller or equal today : First day of rotation
Percentage.MarsPerihelion = d0
d0Year = years_after[:4]
d0Year = int(d0Year)
d0Month = years_after[5:7]
d0Month = int(d0Month)
d0Day = years_after[8:10]
d0Day = int(d0Day)

d0 = date(d0Year, d0Month, d0Day)

d1 = date(
Percentage.current_year,
Percentage.thisMonth,
Percentage.today,
)
if (
d0 <= d1 + timedelta(days=700) and d0 >= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewMarsPerihelion = d0
d1 = date(
Percentage.current_year,
Percentage.thisMonth,
Percentage.today,
)
d1 = d1 + timedelta(days=1)
d3 = Percentage.NewMarsPerihelion - Percentage.MarsPerihelion
d3 = str(d3)
d3 = d3[:3]
d3 = int(d3)
d3 = d3 + 1
ValuePercent = d3 / 100
delta = d1 - Percentage.MarsPerihelion
new = re.sub("[^0-9]", "", str(delta))
new = str(new)
new = new[:3]
new = int(new)

Percentage.MarsResult = new / ValuePercent
Percentage.MarsResult = round(Percentage.MarsResult, 2)

# Add graph progress #####

print("Planet : Mars")
print(("Day of the year : ") + str("Day ") + str(new))
print(
("Year progress : ")
+ str(Percentage.MarsResult)
+ str("%")
)

percent = Percentage.MarsResult

barre = (
"["
+ "#" * int((50 / 100) * percent)
+ "_" * int((50 / 100) * (100 - percent))
+ "]"
)
print("Percent of this year : " + (barre))
print("\n")
Percentage.MarsHTML = (
("Planet : Mars")
+ ("<br />")
+ str(("Day of the year : ") + str("Day ") + str(new))
+ ("<br />")
+ str(
("Year progress : ")
+ str(Percentage.MarsResult)
+ str("%")
+ ("<br />")
)
)
percent = Percentage.MarsResult
barre = (
"["
+ "#" * int((50 / 100) * percent)
+ "_" * int((50 / 100) * (100 - percent))
+ "]"
)
Percentage.barrMars = (
"Percent of this year : " + (barre) + str("\n")
)
Percentage.barrMarsHTML = (
"Percent of this year : " + (barre) + ("<br />")
)
except:
d0Year = years_ago[:4]
d0Year = int(d0Year)
d0Month = years_ago[5:7]
d0Month = int(d0Month)
d0Day = years_ago[8:10]
d0Day = int(d0Day)

d0 = date(d0Year, d0Month, d0Day)
d1 = date(
Percentage.current_year, Percentage.thisMonth, Percentage.today
)
d1 = d1 + timedelta(days=1)
if (
d0 >= d1 - timedelta(days=700) and d0 <= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewMarsPerihelion = d0

for i in thisYear:
d0Year = i[:4]
d0Year = int(d0Year)
d0Month = i[5:7]
d0Month = int(d0Month)
d0Day = i[8:10]
d0Day = int(d0Day)
d0 = date(d0Year, d0Month, d0Day)
d1 = date(
Percentage.current_year,
Percentage.thisMonth,
Percentage.today,
)
if (
d0 <= d1 + timedelta(days=700) and d0 >= d1
): # i is smaller or equal today + 30 days and bigger or equalt today : Next Perihelion
Percentage.NewMarsPerihelion = d0
d1 = date(
Percentage.current_year,
Percentage.thisMonth,
Percentage.today,
)
d3 = (
Percentage.NewMarsPerihelion
- Percentage.MarsPerihelion
)
d3 = str(d3)
d3 = d3[:3]
d3 = int(d3)
d3 = d3 + 1
ValuePercent = d3 / 100
delta = d1 - Percentage.MarsPerihelion
new = re.sub("[^0-9]", "", str(delta))
new = str(new)
new = new[:3]
new = int(new)

Percentage.MarsResult = new / ValuePercent
Percentage.MarsResult = round(Percentage.MarsResult, 2)

# Add graph progress #####

print("Planet : Mars")
print(("Day of the year : ") + str("Day ") + str(new))
print(
("Year progress : ")
+ str(Percentage.MarsResult)
+ str("%")
)

percent = Percentage.MarsResult
barre = (
"["
+ "#" * int((50 / 100) * percent)
+ "_" * int((50 / 100) * (100 - percent))
+ "]"
)
print("Percent of this year : " + (barre))
print("\n")
Percentage.MarsHTML = (
("Planet : Mars")
+ ("<br />")
+ str(("Day of the year : ") + str("Day ") + str(new))
+ ("<br />")
+ str(
("Year progress : ")
+ str(Percentage.MarsResult)
+ str("%")
+ ("<br />")
)
)
percent = Percentage.MarsResult
barre = (
"["
+ "#" * int((50 / 100) * percent)
+ "_" * int((50 / 100) * (100 - percent))
+ "]"
)
Percentage.barrMars = (
"Percent of this year : " + (barre) + str("\n")
)
Percentage.barrMarsHTML = (
"Percent of this year : " + (barre) + ("<br />")
)







"""
Do the same for the moon and other solar system planets, natural satelites, ISS, of all the solar system.
Expand All @@ -1057,6 +1389,7 @@ def Venus(): # d0 = first perihelion , d1 = today , d2 = next perihelion
Moon()
Mercury()
Venus()
Mars()

startHtml = (
str("<!DOCTYPE html>")
Expand Down Expand Up @@ -1125,6 +1458,10 @@ def Venus(): # d0 = first perihelion , d1 = today , d2 = next perihelion
contentHtml.write(Percentage.barrVenusHTML)
contentHtml.write("<br />")
contentHtml.write("<br />")
contentHtml.write(Percentage.MarsHTML)
contentHtml.write(Percentage.barrMarsHTML)
contentHtml.write("<br />")
contentHtml.write("<br />")
contentHtml.write("Developer : Hamdy Abou El Anein - https://github.com/hamdyaea/SolarSystemPercentage")
contentHtml.write("<br />")
contentHtml.write("<br />")
Expand Down
Loading

0 comments on commit 9f21d06

Please sign in to comment.