@@ -24,8 +24,21 @@ def search(self, query):
24
24
25
25
def import_skills (self ):
26
26
previous_save_skills_setting = self .computer .save_skills
27
+
27
28
self .computer .save_skills = False
28
29
30
+ # Make sure it's not over 100mb
31
+ total_size = 0
32
+ for path , dirs , files in os .walk (self .path ):
33
+ for f in files :
34
+ fp = os .path .join (path , f )
35
+ total_size += os .path .getsize (fp )
36
+ total_size = total_size / (1024 * 1024 ) # convert bytes to megabytes
37
+ if total_size > 100 :
38
+ raise Warning (
39
+ f"Skills at path { self .path } can't exceed 100mb. Try deleting some."
40
+ )
41
+
29
42
code_to_run = ""
30
43
for file in glob .glob (os .path .join (self .path , "*.py" )):
31
44
with open (file , "r" ) as f :
@@ -34,7 +47,24 @@ def import_skills(self):
34
47
if self .computer .interpreter .debug :
35
48
print ("IMPORTING SKILLS:\n " , code_to_run )
36
49
37
- self .computer .run ("python" , code_to_run )
50
+ output = self .computer .run ("python" , code_to_run )
51
+
52
+ if "traceback" in output .lower ():
53
+ # Import them individually
54
+ for file in glob .glob (os .path .join (self .path , "*.py" )):
55
+ with open (file , "r" ) as f :
56
+ code_to_run = f .read () + "\n "
57
+
58
+ if self .computer .interpreter .debug :
59
+ print ("IMPORTING SKILL:\n " , code_to_run )
60
+
61
+ output = self .computer .run ("python" , code_to_run )
62
+
63
+ if "traceback" in output .lower ():
64
+ print (
65
+ f"Skill at { file } might be broken— it produces a traceback when run."
66
+ )
67
+
38
68
self .computer .save_skills = previous_save_skills_setting
39
69
40
70
0 commit comments