示例#1
0
    def add_operation(self):
        ''' add operation '''
        type_ = self.liste_type[self.box_type.currentIndex()]
        magasin = self.liste_magasin[self.box_mag.currentIndex()]
        produit = self.liste_produit[self.box_prod.currentIndex()]
        nbr_carton = self.nbr_carton.text()
        date_ = self.date_.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.nbr_carton.text()) != "":
            r = remaining(type_,  nbr_carton, magasin.id, produit.id)
            if r[0] == None:
                raise_error(_(u"error"), r[1])
            else:
                report = Rapport(unicode(type_), int(nbr_carton), datetime_)
                report.magasin = magasin
                report.produit = produit
                report.restant = r[0]
                session.add(report)
                session.commit()
                self.nbr_carton.clear()
                self.table_op.refresh_()
                raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_(u"error"), _(u"Donnez le nbre de carton"))
示例#2
0
    def add_operation(self):
        ''' add operation '''
        type_ = self.liste_type[self.box_type.currentIndex()]
        magasin = self.liste_magasin[self.box_mag.currentIndex()]
        produit = self.liste_produit[self.box_prod.currentIndex()]
        qte_utilise = self.qte_utilise.text()
        date_ = self.date_.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.qte_utilise.text()) != "":
            strap = StockRapport()
            strap.type_ = unicode(type_)
            strap.magasin = magasin
            strap.produit = produit
            strap.qte_utilise = int(qte_utilise)
            strap.date_rapp = datetime_
            strap.restant = 0
            strap.save()
            self.qte_utilise.clear()
            self.table_op.refresh_()
            raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_(u"error"), _(u"Give the quantity used"))
示例#3
0
    def add_chiks(self):
        ''' add operation '''

        date_ = self.date_report.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        chicken_coop = self.list_chicken_coop[self.chicken_coop.currentIndex()]
        print chicken_coop.id
        datetime_ = datetime(int(year), int(month), int(day), int(dt.hour),
                             int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.nb_death.text()) != "":
            ps = PsRapport()
            ps.nb_death = int(self.nb_death.text())
            ps.weight = int(self.weight.text())
            ps.nb_eggs = int(self.nb_eggs.text())
            ps.date_report = datetime_
            ps.psarrivage = chicken_coop.id
            ps.save()
            self.nb_death.clear()
            self.nb_eggs.clear()
            self.weight.clear()
            self.chiks_table.refresh_()
        else:
            raise_error(_("Error"), _(u"Give the number of the death"))
示例#4
0
    def add_operation(self):
        ''' add operation '''

        if unicode(self.name.text()) != "":
            magasin = Magasin(unicode(self.name.text()))
            session.add(magasin)
            session.commit()
            self.name.clear()
            self.stori_table.refresh_()
            raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the name of the store"))
示例#5
0
    def add_operation(self):
        ''' add operation '''

        if unicode(self.name.text()) != "":
            magasin = Magasin()
            magasin.name = unicode(self.name.text())
            magasin.qte_maxi_stok = int(self.qte_maxi_stok.text())
            magasin.save()
            self.name.clear()
            self.qte_maxi_stok.clear()
            self.stori_table.refresh_()
            raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the name of the store"))
示例#6
0
def export_command_as_excel(comm):

    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(),
                                      _(u"Save Excel Export as..."),
                                    "%s.xls" % datetime.now()
                                        .strftime('%x %Hh%M'), "*.xls")
    if not destination:
        return
    try:
        write_command_xls(destination, comm)
        raise_success(_(u"Success"),
                      _(u"Les données ont été exportées correctement."))
    except IOError:
        raise_error(u"La commande n'a pas pu être exportée.",
                    u"Vérifiez le chemin de destination puis re-essayez.\n\n"
                    u"Demandez de l'aide si le problème persiste.")
示例#7
0
文件: model.py 项目: fadiga/syesulu
    def save(self):
        """
        Calcul du restant en stock après une operation."""
        from util import raise_success, raise_error

        last_reports = StockRapport.filter(produit__libelle=self
                                           .produit.libelle,
                                           magasin__name=self.magasin.name,
                                           date_rapp__lt=self.date_rapp) \
                                    .order_by(('date_rapp','desc'))
        previous_remaining = 0
        self.restant = 0
        try:
            last_reports = last_reports.get()
        except:
            last_reports = None

        if last_reports == None and self.type_ == _(u"inout"):
            raise_error(_(u"error"), \
                        _(u"Il n'existe aucun %s dans le magasin %s") % \
                        (self.produit.libelle, self.magasin.name))
            return False
        if last_reports:
            previous_remaining = last_reports.restant
            if self.type_ == _(u"input"):
                self.restant = previous_remaining + self.qte_utilise
            if self.type_ == _(u"inout"):
                self.restant = previous_remaining - self.qte_utilise
                if self.restant < 0:
                    print  self.qte_utilise, previous_remaining
                    raise_error(_(u"error"), _(u"On peut pas utilisé %d puis qu'il ne reste que %d") % \
                                       (self.qte_utilise, previous_remaining))
                    return False
        else:
            self.restant = self.qte_utilise
        super(StockRapport, self).save()
        raise_success(_(u"Confirmation"), _(u"Registered operation"))
        # ----------------------------------------------------------------#
        next_reports = StockRapport.filter(produit__libelle=self.produit \
                                .libelle, magasin__name=self.magasin.name, \
                        date__gt=self.date_rapp).order_by(('date_rapp', 'asc'))
        try:
            next_reports = next_reports.get()
        except:
            next_reports = None
        if next_reports:
            next_reports.save()
示例#8
0
def export_database_as_excel():

    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(),
                                    _(u"Save Excel Export as..."),
                                    "%s.xls" % datetime.now()
                                    .strftime(u"%X %Hh%M"), "*.xls")
    if not destination:
        return
    try:
        write_xls(destination)
        raise_success(u"Les données ont été exportées correctement.",
                      u"Conservez ce fichier précieusement car il contient "
                      u"toutes vos données.\n\n"
                      u"Exportez vos données régulièrement.")
    except IOError:
        raise_error(u"La base de données n'a pas pu être exportée.",
                    u"Vérifiez le chemin de destination puis re-essayez.\n\n"
                    u"Demandez de l'aide si le problème persiste.")
示例#9
0
 def add_operation(self):
     ''' add operation '''
     unite_ = self.liste_unite[self.box_unite.currentIndex()]
     if unicode(self.libelle.text()) != "":
         if unicode(unite_) != "":
             produit = Produit()
             produit.libelle = unicode(self.libelle.text())
             produit.unite = unicode(unite_)
             produit.save()
             self.libelle.clear()
             self.table_op.refresh_()
             raise_success(_(u"Confirmation"), _(u"The product %s "
                           u" was recorded") % produit.libelle)
         else:
             raise_error(_(u"error"), \
                         _(u"Give the room number in the box"))
     else:
         raise_error(_(u"Error"), _(u"Give the name of the product"))
示例#10
0
文件: exports.py 项目: fadiga/syesulu
def export_database_as_file():
    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(),
                                    _(u"Sauvegarder la base de Donnée."),
                                      u"%s.db" % datetime.now()\
                                                .strftime(u'%x-%Hh%M'),
                                    "*.db")
    if not destination:
        return None

    try:
        shutil.copyfile(model.DB_FILE, destination)
        raise_success(u"Les données ont été exportées correctement.",
                      u"Conservez ce fichier précieusement car il "
                      u"contient toutes vos données.\n"
                      u"Exportez vos données régulièrement.")
    except IOError:
        raise_error(u"La base de données n'a pas pu être exportée.",
                    u"Vérifiez le chemin de destination puis re-essayez.\n\n"
                    u"Demandez de l'aide si le problème persiste.")
示例#11
0
文件: model.py 项目: fadiga/syesulu
    def save(self):
        """
        Calcul du restant en stock après une operation."""
        from util import raise_success, raise_error
        try:
            last_reports = PsRapport.filter(psarrivage__chicken_coop_id= \
                           self.psarrivage).order_by(('date_report', 'desc'))
        except:
            raise_error(_("Error"), _(u"Ce poulailler est vide"))
            return False
        previous_remaining = 0
        self.remaining = 0
        try:
            last_report = last_reports.get()
        except:
            last_report = None

        if last_report:
            previous_remaining = last_report.remaining
            self.remaining = previous_remaining - self.nb_death
            if self.remaining < 0:
                raise_error(_(u"error"), \
                    _(u"On peut pas utilisé %d puis qu'il ne reste que %d") % \
                    (self.nb_death, previous_remaining))
                return False
        else:
            self.remaining = self.psarrivage.nb_total_chiks - self.nb_death

        super(PsRapport, self).save()
        raise_success(_(u"Confirmation"), _(u"Registered operation"))
        # ----------------------------------------------------------------#
        next_reports = PsRapport.filter(psarrivage=self.psarrivage, \
                                        date_report__gt=self.date_report) \
                                .order_by(('date_report', 'asc'))

        try:
            next_reports = next_reports.get()
        except:
            next_reports = None

        if next_reports:
            next_reports.save()
示例#12
0
 def add_chickencoop(self):
     ''' add operation '''
     date_ = self.date.text()
     day, month, year = date_.split('/')
     dt = datetime.now()
     datetime_ = datetime(int(year), int(month), int(day),
                          int(dt.hour), int(dt.minute), int(dt.second),
                          int(dt.microsecond))
     if unicode(self.num.text()) != "":
         poussin = ChickenCoop()
         poussin.type_ = int(self.type_.currentIndex())
         poussin.num = int(self.num.text())
         poussin.nbr_sujet_maxi = int(self.nbr_sujet_maxi.text())
         poussin.date = datetime_
         poussin.save()
         self.num.clear()
         self.nbr_sujet_maxi.clear()
         self.poussin_table.refresh_()
         raise_success(_(u"Confirmation"), _(u"Registered operation"))
     else:
         raise_error(_("Error"), _(u"Give the name of the store"))
示例#13
0
 def edit_prod(self):
     produit = session.query(Produit)\
                      .filter(Produit.libelle == self.prod.libelle) \
                      .filter(Produit.nbr_piece == self.prod.nbr_piece)\
                      .all()[0]
     lib = unicode(self.new_produit.text())
     nbr = self.new_nbr_piece.text()
     if lib != "":
         if unicode(nbr) != "":
             is_double = session.query(Produit)\
                       .filter(Produit.libelle==lib).all() == []
             if is_double:
                 produit = Produit(lib, int(nbr))
                 session.add(produit)
                 session.commit()
                 raise_success(_(u"Confirmation"), _(u"The product has been changing"))
                 self.cancel()
             else:
                 raise_error(_(u"error"), \
                             _(u"Ce produit existe déjà"))
         else:
             raise_error(_(u"error"), \
                         _(u"Give the room number in the box"))
     else:
         raise_error(_(u"Error"), _(u"Give the name of the product"))
示例#14
0
 def add_operation(self):
     ''' add operation '''
     lib = unicode(self.libelle.text())
     nbr = self.nbre_piece.text()
     if lib != "":
         if unicode(nbr) != "":
             is_double = session.query(Produit)\
                       .filter(Produit.libelle==lib).all() == []
             if is_double:
                 produit = Produit(lib, int(nbr))
                 session.add(produit)
                 session.commit()
                 self.libelle.clear()
                 self.nbre_piece.clear()
                 self.table_op.refresh_()
                 raise_success(_(u"Confirmation"), _(u"The product %s "
                               u" was recorded") % produit.libelle)
             else:
                 raise_error(_(u"error"), \
                             _(u"Ce produit existe déjà"))
         else:
             raise_error(_(u"error"), \
                         _(u"Give the room number in the box"))
     else:
         raise_error(_(u"Error"), _(u"Give the name of the product"))
示例#15
0
文件: chiks.py 项目: fadiga/syesulu
    def add_chiks(self):
        ''' add operation '''

        date_ = self.date_arriver.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        chicken_coop = self.list_chicken_coop[self.chicken_coop.currentIndex()]
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.nb_total_chiks.text()) != "" :
            if int(self.nb_total_chiks.text()) >= chicken_coop.nbr_sujet_maxi:
                raise_error(_("Error"), _(u"%s can take only %s chicks") \
                    % (chicken_coop.full_name(), chicken_coop.nbr_sujet_maxi))
            else:
                if chicken_coop.status == 1:
                    raise_error(_("Error"), _(u"%s est occupée") \
                    % (chicken_coop.full_name()))
                else:
                    ps = PsArrivage()
                    ps.race = unicode(self.race.text())
                    ps.nb_total_chiks = int(self.nb_total_chiks.text())
                    ps.arrival_date = datetime_
                    ps.chicken_coop = chicken_coop
                    ps.chicken_coop.status = 1
                    chicken_coop.save()
                    ps.save()
                    self.nb_total_chiks.clear()
                    self.race.clear()
                    self.chiks_table.refresh_()
                    raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the number of the chiks"))
示例#16
0
def convert(TMP_FOLDER,
            infile,
            outfile,
            outsize,
            outfstype,
            inPWD=None,
            outPWD=None,
            out_mount_options=None):
    source = "%s/source" % TMP_FOLDER
    target = "%s/target" % TMP_FOLDER

    sh << "mkdir %(source)s %(target)s" > None
    sh.r == 0 or raise_error()
    mount(infile, source, pwd=inPWD)

    if outfile.startswith("/dev/"):
        print "outfile startswith /dev/"
        stdout = sh << "blockdev --getsize64 %(outfile)s" > str
        outsize = "%s" % int(stdout)
        print "size changed to %s = sizeof(%s)" % (outsize, outfile)

        while True:
            outfile_tmp = raw_input('write path for outfile_tmp:')
            print "tmpfile: %s" % outfile_tmp
            if os.path.exists(outfile_tmp):
                print "file %s exist, try another file path"
            else:
                break
    else:
        outfile_tmp = "%s.tmp" % outfile

    print "creating outfile"
    create(outfile_tmp, outsize, outfstype, pwd=outPWD)
    print "mounting outfile (%s)" % out_mount_options
    mount(outfile_tmp, target, pwd=outPWD, options=out_mount_options)

    print "copying files to new image"
    sh << "cd %(source)s; cp2 ./ %(target)s" > None
    sh.r == 0 or raise_error()
    print "copy task completed"

    print "umounting source"
    sh << "umountlist %(source)s | sh" > None

    print "umounting tmp disk"
    sh << "umountlist %(target)s | sh" > None
    sh.r == 0 or raise_error()

    if outfile == infile:
        print "FIXME: convert to same file incomplete"
        raise_error()
        # print "temporarily umounting source"
        # source_umount_list = sh << "umountlist %(source)s" > str
        # run("umount %s" % source) or exit(1)

    if outfile.startswith("/dev/") and not outfile.startswith("/dev/shm/"):
        answer = ""
        while answer != "yes":
            print "command : dd2 if=%s of=%s" % (outfile_tmp, outfile)
            answer = raw_input('write yes for run this command: ')
        print "copying to device"
        sh << "dd2 if=%(outfile_tmp)s of=%(outfile)s oflag=direct bs=64K" > None
        sh << "rm -f %(outfile_tmp)s" > None
    else:
        sh << "mv %(outfile_tmp)s %(outfile)s" > None

    if outfile == infile:
        print "FIXME: convert to same file incomplete"
        raise_error()
        # print "umounting source"
        # run("%s" % source_umount_list)

    sh << "rmdir %(TMP_FOLDER)s/source" > None
    sh << "rmdir %(TMP_FOLDER)s/target" > None