Skip to content

Commit

Permalink
Adding loop for file transfer bot. (nus-ncl#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
ariscahyadi authored Apr 17, 2023
1 parent 72eb315 commit 24e564f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Octo-Bot/file-transfer-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ $ docker run file-transfer-bot:latest
usage: ftp_starter.py [-h] -s SERVER -u USERNAME --p PASSWORD
[-d TIME (Second)] [-t THREAD -f FUNCTION]
[-uf UPLOAD_FILE] [-df DOWNLOAD_FILE]
[-l NUMBER_OF_LOOP]
```
9 changes: 7 additions & 2 deletions Octo-Bot/file-transfer-bot/bot/ftp_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@ def main():
default=['/large_file'])
parser.add_argument("-df", metavar = 'downloaded_file',required=False, nargs='+',
help="file to be downloaded",default=['large_file'])
parser.add_argument("-l", metavar = 'loop', help="number of loop (default 1)", type=int,required=False,
default=1)

args = parser.parse_args()
loop = 0

if args.f[0] == 'upload':
while True:
while loop < args.l:
scheduleUpload(args)
time.sleep(random.uniform(0, args.d))
loop = loop+1
elif args.f[0] == 'download':
while True:
while loop < args.l:
scheduleDownload(args)
time.sleep(random.uniform(0, args.d))
loop = loop+1
else:
parser.print_help()

Expand Down

0 comments on commit 24e564f

Please sign in to comment.