Subversion Repositories SmartDukaan

Rev

Rev 20997 | Rev 22240 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20997 Rev 21265
Line 337... Line 337...
337
        return str1
337
        return str1
338
    except:
338
    except:
339
        ssh_client = SSHClient()
339
        ssh_client = SSHClient()
340
        str1 = ""
340
        str1 = ""
341
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
341
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
342
        ssh_client.connect('dtr', 22, 'root', 'ecip$dtrMay2014')
342
        ssh_client.connect('dtr', 22, 'root', 'spic@2015dtr')
343
        sftp_client = ssh_client.open_sftp()
343
        sftp_client = ssh_client.open_sftp()
344
        try:
344
        try:
345
            if not os.path.exists(os.path.dirname(fileName)):
345
            if not os.path.exists(os.path.dirname(fileName)):
346
                os.makedirs(os.path.dirname(fileName))
346
                os.makedirs(os.path.dirname(fileName))
347
            sftp_client.get(fileName, fileName)
347
            sftp_client.get(fileName, fileName)
Line 469... Line 469...
469
        m.setFrom(mFrom)
469
        m.setFrom(mFrom)
470
        for receipient in MAILTO:
470
        for receipient in MAILTO:
471
            m.addRecipient(receipient)
471
            m.addRecipient(receipient)
472
        m.setSubject(title)
472
        m.setSubject(title)
473
        m.send()
473
        m.send()
474
    return    
-
 
475
474
    return    
-
 
475
 
-
 
476
 
-
 
477
 
-
 
478
 
-
 
479
 
-
 
480
 
-
 
481
 
-
 
482
 
-
 
483
 
-
 
484
 
-
 
485
 
-
 
486
 
-
 
487
 
-
 
488
from jsonfinder import jsonfinder
-
 
489
import requests
-
 
490
 
-
 
491
def readSSh(fileName):
-
 
492
    try:
-
 
493
        str1 = open(fileName).read()
-
 
494
        return str1
-
 
495
    except:
-
 
496
        ssh_client = SSHClient()
-
 
497
        str1 = ""
-
 
498
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-
 
499
        ssh_client.connect('dtr', 22, 'root', 'spic@2015dtr')
-
 
500
        sftp_client = ssh_client.open_sftp()
-
 
501
        try:
-
 
502
            if not os.path.exists(os.path.dirname(fileName)):
-
 
503
                os.makedirs(os.path.dirname(fileName))
-
 
504
            sftp_client.get(fileName, fileName)
-
 
505
            try:
-
 
506
                str1 = open(fileName).read()
-
 
507
                return str1
-
 
508
            finally:
-
 
509
                pass
-
 
510
        except:
-
 
511
            "could not read"
-
 
512
        return str1
-
 
513
if __name__ == '__main__':
-
 
514
    content = readSSh("/home/amit/Downloads/flipkarthtml")
-
 
515
    print content
-
 
516
    for _, __, obj in jsonfinder(content, json_only=True):
-
 
517
        if (obj and
-
 
518
            isinstance(obj, list) and
-
 
519
            isinstance(obj[0], dict) and
-
 
520
            {'player_id', 'event_id', 'name'}.issubset(obj[0])
-
 
521
            ):
-
 
522
            break
-
 
523
        else:
-
 
524
            raise ValueError('data not found')
-
 
525
 
-
 
526
    # Now you can use obj
-
 
527
    print(len(obj))
-
 
528
    print(obj[0])
-
 
529