Skip to content

Commit 1bb2919

Browse files
committed
Fix filenames in commands + add success messages
1 parent 3145cda commit 1bb2919

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

prework.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def check_file(filename, correct_hash=None, different_hash=None, correct_perms=N
7575
with open(filename, 'rb') as file_reader:
7676
file_content = file_reader.read()
7777
file_hash = hashlib.sha256(file_content).hexdigest()
78-
file_perms = oct(os.stat('intro.txt').st_mode)[-3:]
78+
file_perms = oct(os.stat(filename).st_mode)[-3:]
7979

8080
if correct_hash and file_hash != correct_hash:
8181
result += 1
@@ -101,7 +101,7 @@ def check_challenge_1():
101101
result = check_file('intro.txt', different_hash=original_hash, correct_perms="644")
102102
dramatic_print([f"Checking for changes to intro.txt.", ".", ". "])
103103
if result == 0:
104-
print(f"✅ Correct!")
104+
print(f"✅ Challenge 1 Complete!")
105105
with open('challenge_1.sh', 'r') as chal:
106106
print(f"Your command was:\n\t> {chal.read()}\n")
107107
return True
@@ -110,8 +110,8 @@ def check_challenge_1():
110110
return False
111111
elif result == 4:
112112
print(f"🚧 Your command ran, but the file permissions for input changed when they shouldn't have. Please check your command and try again.")
113-
print(f"\tOriginal permissions:\tpermanent.txt (644)")
114-
print(f"\tYour permissions:\tpermanent.txt ({oct(os.stat('permanent.txt').st_mode)[-3:]})\n")
113+
print(f"\tOriginal permissions:\intro.txt (644)")
114+
print(f"\tYour permissions:\intro.txt ({oct(os.stat('intro.txt').st_mode)[-3:]})\n")
115115
return False
116116
else:
117117
print(f"⛔ Sorry, that's not the right answer. Please make sure your challenge_1 command modifies the file's content, but not its' permissions. Error code: {result}\n")
@@ -129,7 +129,7 @@ def check_challenge_2():
129129

130130
dramatic_print([f"Checking for changes to permanent.txt.", ".", ". "])
131131
if result == 4 and not has_write:
132-
print(f"✅ Correct!")
132+
print(f"✅ Challenge 2 Complete!")
133133
with open('challenge_2.sh', 'r') as chal:
134134
print(f"Your command was:\n\t> {chal.read()}\n")
135135
return True
@@ -169,7 +169,7 @@ def check_challenge_3():
169169
print(f"⛔ Sorry, that's not the right answer. Please make sure your command creates a new file called copy.txt\n")
170170
return False
171171
if result2 == 0:
172-
print(f"✅ Correct!")
172+
print(f"✅ Challenge 3 Complete!")
173173
with open('challenge_3.sh', 'r') as chal:
174174
print(f"Your command was:\n\t> {chal.read()}\n")
175175
return True

0 commit comments

Comments
 (0)