@ -2,6 +2,9 @@
import math
import math
from subprocess import Popen
from subprocess import Popen
from os import name
from os import name
from prawcore import ResponseException
from reddit . subreddit import get_subreddit_threads
from reddit . subreddit import get_subreddit_threads
from utils . cleanup import cleanup
from utils . cleanup import cleanup
from utils . console import print_markdown , print_step
from utils . console import print_markdown , print_step
@ -51,14 +54,20 @@ def main(POST_ID=None):
def run_many ( times ) :
def run_many ( times ) :
for x in range ( 1 , times + 1 ) :
for x in range ( 1 , times + 1 ) :
print_step (
print_step (
f ' on the { x } { ( " th " , " st " , " nd " , " rd " , " th " , " th " , " th " , " th " , " th " , " th " ) [ x % 10 ] } iteration of { times } '
f ' on the { x } { ( " th " , " st " , " nd " , " rd " , " th " , " th " , " th " , " th " , " th " , " th " ) [ x % 10 ] } iteration of { times } '
) # correct 1st 2nd 3rd 4th 5th....
) # correct 1st 2nd 3rd 4th 5th....
main ( )
main ( )
Popen ( " cls " if name == " nt " else " clear " , shell = True ) . wait ( )
Popen ( " cls " if name == " nt " else " clear " , shell = True ) . wait ( )
def shutdown ( ) :
print_markdown ( " ## Clearing temp files " )
cleanup ( )
exit ( )
if __name__ == " __main__ " :
if __name__ == " __main__ " :
config = settings . check_toml ( " .config.template.toml " , " config.toml " )
config = settings . check_toml ( " utils/ .config.template.toml" , " config.toml " )
config is False and exit ( )
config is False and exit ( )
try :
try :
if config [ " settings " ] [ " times_to_run " ] :
if config [ " settings " ] [ " times_to_run " ] :
@ -68,13 +77,19 @@ if __name__ == "__main__":
for index , post_id in enumerate ( config [ " reddit " ] [ " thread " ] [ " post_id " ] . split ( " + " ) ) :
for index , post_id in enumerate ( config [ " reddit " ] [ " thread " ] [ " post_id " ] . split ( " + " ) ) :
index + = 1
index + = 1
print_step (
print_step (
f ' on the { index } { ( " st " if index % 10 == 1 else ( " nd " if index % 10 == 2 else ( " rd " if index % 10 == 3 else " th " ) ) ) } post of { len ( config [ " reddit " ] [ " thread " ] [ " post_id " ] . split ( " + " ) ) } '
f ' on the { index } { ( " st " if index % 10 == 1 else ( " nd " if index % 10 == 2 else ( " rd " if index % 10 == 3 else " th " ) ) ) } post of { len ( config [ " reddit " ] [ " thread " ] [ " post_id " ] . split ( " + " ) ) } '
)
)
main ( post_id )
main ( post_id )
Popen ( " cls " if name == " nt " else " clear " , shell = True ) . wait ( )
Popen ( " cls " if name == " nt " else " clear " , shell = True ) . wait ( )
else :
else :
main ( )
main ( )
except KeyboardInterrupt :
except KeyboardInterrupt :
print_markdown ( " ## Clearing temp files " )
shutdown ( )
cleanup ( )
except ResponseException :
exit ( )
# error for invalid credentials
print_markdown ( " ## Invalid credentials " )
print_markdown ( " Please check your credentials in the config.toml file " )
shutdown ( )
# todo error