(self, edit)
| 397 | |
| 398 | class CurlDownloadFileCommand(sublime_plugin.TextCommand): |
| 399 | def run(self, edit): |
| 400 | text = get_buffer_text(self.view).strip('\n') |
| 401 | global workdir |
| 402 | file = write_file(workdir,text) |
| 403 | ticks = str(int(time.time())) |
| 404 | |
| 405 | workdir = os.path.join(HOME,'Desktop','work') |
| 406 | dwdir = os.path.join(workdir,ticks) |
| 407 | |
| 408 | if os.path.exists(workdir) == False: |
| 409 | os.mkdir(workdir) |
| 410 | os.mkdir(dwdir) |
| 411 | else: |
| 412 | os.mkdir(dwdir) |
| 413 | |
| 414 | errurls = is_url(text.split('\n')) |
| 415 | if len(errurls) > 0: |
| 416 | sublime.message_dialog('[error] Urls are invaild! Please check...') |
| 417 | panel_print(self.view, edit, '[-] The invaild urls:\n' + errurls) |
| 418 | return |
| 419 | |
| 420 | if os.path.exists(workdir): |
| 421 | if platform == 'windows': |
| 422 | cmd = '"cd {dir} && FOR /f %f IN ({file}) DO curl -k -O %f"'.format(dir=dwdir,file=file) |
| 423 | else: |
| 424 | cmd = 'cd {dir};for line in $(cat {file});do curl -k -O ${line};done;'.format(dir=dwdir,file=file,line='{line}') |
| 425 | exec_command(cmd) |
| 426 | else: |
| 427 | panel_print(self.view, edit, '[!] $HOME/Desktop/work folder not exists!') |
| 428 | |
| 429 | |
| 430 | # Format tools result |
nothing calls this directly
no test coverage detected