1 ImportArgparse2 ImportOS3 ImportRequests4 5 6HEADERS = {7 'user-agent':'mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36'8 '(khtml, like Gecko) chrome/56.0.2924.87 safari/537.36'9 }Ten OneExt_url="https://{0}.gallery.vsassets.io/_apis/public/gallery/publisher/{1}/extension/{2}/{3}/assetbyname/ Microsoft.VisualStudio.Services.VSIXPackage" A - defDownload_ext (publisher,name,ver): -Url=Ext_url.format (publisher,publisher,name,ver) the Print(URL) -Res=requests.get (url,headers=HEADERS) - res.raise_for_status () -Playfile = open (publisher+'.'+name+'. VSIX','WB') + forChunkinchRes.iter_content (1024): - Playfile.write (Chunk) + playfile.close () A at - defarg_parse (): -Parse=argparse. Argumentparser (description='vscode Extension Download CLI Tools') -Parse.add_argument ("- I.",'--identifier', type=str,help='Extension Unique identifier') -Parse.add_argument ('- v','--version', type=str,help='Extension Version') - returnParse in - defcommand_parse (): toParse=Arg_parse () +args=VARs (Parse.parse_args ()) - Print(args) the *key=args["identifier"] $ Panax NotoginsengIndex=key.find ('.') -Publisher=Key[:index] theName=key[index+1:] +Download_ext (publisher,name,args['version']) A the + if __name__=="__main__": - Command_parse () $
Offline download vs code plugin Python source