Subversion Repositories basico

Rev

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

Rev 142 Rev 144
Line 472... Line 472...
472
        else:
472
        else:
473
            self.alert.show('Import', 'Nothing imported', 'error')
473
            self.alert.show('Import', 'Nothing imported', 'error')
474
            self.debug("Nothing imported")
474
            self.debug("Nothing imported")
475
        dialog.destroy()
475
        dialog.destroy()
476
476
477
    def import_notes_from_sapnet(self, lines):
-
 
-
 
477
    def import_notes_from_sapnet(self, bag):
478
        db = self.get_service('DB')
478
        db = self.get_service('DB')
479
        driver = self.get_service('Driver')
479
        driver = self.get_service('Driver')
480
-
 
481
        #~ notebook = self.gui.get_widget('notebook')
-
 
482
        winroot = self.gui.get_widget('mainwindow')
480
        winroot = self.gui.get_widget('mainwindow')
483
        sapnotes = []
-
 
484
        bag = set()
-
 
485
        lines = lines.replace(' ', ',')
-
 
486
        lines = lines.replace('\n', ',')
-
 
487
        sapnotes.extend(lines.split(','))
-
 
488
-
 
489
        for sapnote in sapnotes:
-
 
490
            if len(sapnote.strip()) > 0:
-
 
491
                bag.add(sapnote.strip())
-
 
492
-
 
493
        self.debug("%d SAP Notes to be downloaded: %s" % (len(bag), ', '.join(list(bag))))
481
        self.debug("%d SAP Notes to be downloaded: %s" % (len(bag), ', '.join(list(bag))))
494
482
495
        resnotes = {}
-
 
-
 
483
        result = {}
496
484
497
        self.sap.start_fetching(len(bag))
485
        self.sap.start_fetching(len(bag))
498
        dlbag = []
486
        dlbag = []
499
487
500
        # FIXME: max_workers = 1 = Threads disabled
488
        # FIXME: max_workers = 1 = Threads disabled
Line 505... Line 493...
505
                jobs.append(job)
493
                jobs.append(job)
506
494
507
            for job in jobs:
495
            for job in jobs:
508
                rc, sapnote = job.result()
496
                rc, sapnote = job.result()
509
                self.debug("\tRC SAP Note %s: %s" % (sapnote, rc))
497
                self.debug("\tRC SAP Note %s: %s" % (sapnote, rc))
510
                resnotes[sapnote] = rc
-
 
-
 
498
                result[sapnote] = rc
511
                if rc:
499
                if rc:
512
                    sid = "0"*(10 - len(sapnote)) + sapnote
500
                    sid = "0"*(10 - len(sapnote)) + sapnote
513
                    dlbag.append(sid)
501
                    dlbag.append(sid)
514
                time.sleep(0.2)
502
                time.sleep(0.2)
515
503
516
        driver.close()
504
        driver.close()
517
        self.sap.stop_fetching()
505
        self.sap.stop_fetching()
518
        db.save_notes()
506
        db.save_notes()
519
        db.build_stats()
507
        db.build_stats()
520
        dlbag.sort()
-
 
521
        package = self.db.get_package(dlbag)
-
 
522
        menuview = self.gui.get_widget('viewmenu')
-
 
523
        menuview.populate(package)
-
 
524
        visor = self.gui.get_widget('visor')
-
 
525
        visor.populate(dlbag)
-
 
526
        self.debug("Task completed.")
508
        self.debug("Task completed.")
-
 
509
        return result
-
 
510
        # ~ dlbag.sort()
-
 
511
        # ~ package = self.db.get_package(dlbag)
-
 
512
        # ~ menuview = self.gui.get_widget('viewmenu')
-
 
513
        # ~ menuview.populate(package)
-
 
514
        # ~ visor = self.gui.get_widget('visor')
-
 
515
        # ~ visor.populate(dlbag)
-
 
516
527
        #~ notebook.set_current_page(0)
517
        #~ notebook.set_current_page(0)
528
        #~ dialog = Gtk.MessageDialog(winroot, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Task completed")
518
        #~ dialog = Gtk.MessageDialog(winroot, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Task completed")
529
        #~ msgrc = ""
519
        #~ msgrc = ""
530
        #~ ko = 0
520
        #~ ko = 0
531
        #~ ok = 0
521
        #~ ok = 0