1010sys .path .insert (0 , os .path .join (os .path .dirname (os .path .realpath (sys .argv [0 ])), '..' ))
1111from sdcclient import SdcClient
1212
13+
1314def zipdir (path , ziph ):
1415 # ziph is zipfile handle
1516 for root , dirs , files in os .walk (path ):
1617 for file in files :
1718 ziph .write (os .path .join (root , file ))
1819
20+
1921def cleanup_dir (path ):
2022 if os .path .exists (path ) == False :
2123 return
2224 if os .path .isdir (path ) == False :
23- print 'Provided path is not a directory'
25+ print ( 'Provided path is not a directory' )
2426 sys .exit (- 1 )
2527
2628 for file in os .listdir (path ):
@@ -29,17 +31,18 @@ def cleanup_dir(path):
2931 if os .path .isfile (file_path ):
3032 os .unlink (file_path )
3133 else :
32- print 'Cannot clean the provided directory due to delete failure on %s' % file_path
34+ print ( 'Cannot clean the provided directory due to delete failure on %s' % file_path )
3335 except Exception as e :
3436 print (e )
3537 os .rmdir (path )
3638
39+
3740#
3841# Parse arguments
3942#
4043if len (sys .argv ) != 3 :
41- print 'usage: %s <sysdig-token> <file-name>' % sys .argv [0 ]
42- print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
44+ print ( 'usage: %s <sysdig-token> <file-name>' % sys .argv [0 ])
45+ print ( 'You can find your token at https://app.sysdigcloud.com/#/settings/user' )
4346 sys .exit (1 )
4447
4548sdc_token = sys .argv [1 ]
@@ -54,15 +57,13 @@ def cleanup_dir(path):
5457#
5558# Fire the request.
5659#
57- res = sdclient .get_dashboards ()
60+ ok , res = sdclient .get_dashboards ()
5861
5962#
6063# Show the list of dashboards
6164#
62- if res [0 ]:
63- data = res [1 ]
64- else :
65- print res [1 ]
65+ if not ok :
66+ print (res )
6667 sys .exit (1 )
6768
6869
@@ -74,11 +75,11 @@ def cleanup_dir(path):
7475 os .makedirs (sysdig_dashboard_dir )
7576
7677
77- for db in data ['dashboards' ]:
78+ for db in res ['dashboards' ]:
7879 file_path = os .path .join (sysdig_dashboard_dir , str (db ['id' ]))
7980 f = open (file_path , 'w' )
8081 f .write (json .dumps (db ))
81- print "Name: %s, # Charts: %d" % (db ['name' ], len (db ['items' ]))
82+ print ( "Name: %s, # Charts: %d" % (db ['name' ], len (db ['items' ]) ))
8283 f .close ()
8384
8485zipf = zipfile .ZipFile (dashboard_state_file , 'w' , zipfile .ZIP_DEFLATED )
0 commit comments