def unwatch_command(self, email, repo):
          
        if(repo == ""):
            db.delete_subscribtions(email)
            message = "All your subscribtions were removed from database !"
        else:
            db.delete_subscribtion(email,repo)
            message = "The repository is not watched anymore !"

        xmpp.send_message(email, message)
 def unmute_command(self, email, repo):
     
     if(repo == ""):
         db.enable_subscriptions(email);
         message = "All repositories you subscribed are now unmuted !"
     else:
         db.enable_subscription(email, repo)
         message = "Repository " + repo + " is now unmuted !"
     
     xmpp.send_message(email, message)
    def unmute_command(self, email, repo):

        if (repo == ""):
            db.enable_subscriptions(email)
            message = "All repositories you subscribed are now unmuted !"
        else:
            db.enable_subscription(email, repo)
            message = "Repository " + repo + " is now unmuted !"

        xmpp.send_message(email, message)
    def unwatch_command(self, email, repo):

        if (repo == ""):
            db.delete_subscribtions(email)
            message = "All your subscribtions were removed from database !"
        else:
            db.delete_subscribtion(email, repo)
            message = "The repository is not watched anymore !"

        xmpp.send_message(email, message)
    def post(self):
        
        message = xmpp.Message(self.request.POST)
        
        
        
        email_pattern = re.compile('([\w\-\.]+@(\w[\w\-]+\.)+[\w\-]+)')
        result = email_pattern.match(message.sender)
        mail = result.group(0)
        
        keyname = mail
        
        e = db.developpers.get_or_insert(keyname, Mail=mail)
        
        if(message.body=='!unmute'):
            
            e.Active = True
            e.put()

        elif(message.body=='!mute'):
            
            e.Active = False
            e.put()           
            
        else:
            
            f = db.xmpp_in(From = message.sender)
            f.Body = message.body
            f.When = datetime.datetime.now()
            f.put()
Exemple #6
0
    def log_post_data(self, body):

        #DEBUG: log json data "as is", create new db entry
        db_log_payload = db.github_in()
        db_log_payload.When = datetime.datetime.now()
        db_log_payload.Body = body
        db_log_payload.put()
 def log_post_data(self, body):
     
     #DEBUG: log json data "as is", create new db entry
     db_log_payload = db.github_in()
     db_log_payload.When = datetime.datetime.now()
     db_log_payload.Body = body
     db_log_payload.put()
    def post(self):
        
        message = xmpp.Message(self.request.POST)
        
        #DEBUG: log xmmp input
        log_xmpp_in = db.xmpp_in(From = message.sender)
        log_xmpp_in.Body = message.body
        log_xmpp_in.When = datetime.datetime.now()
        log_xmpp_in.put()
        
        
        #Split message body into args array
        args = message.body.split(" ")
        command = args[0]
        
        
        #try to read parameters ?
        try:
            repo = args[1]
        except IndexError:
            repo = ""
        
        
        
        #Parse sender JID to extract email        
        email_pattern = re.compile('([\w\-\.]+@(\w[\w\-]+\.)+[\w\-]+)')
        result = email_pattern.match(message.sender)
        email = result.group(0)

        if(command=='!mute'):
            #mute (or stop watching) all or one repository
            self.mute_command(email, repo)
        elif(command=='!unmute'):
            #unmute (or start watching) all or one repository
            self.unmute_command(email, repo)        
        elif(command=='!watch'):
            #start watching one repository
            self.watch_command(email, repo)
        elif(command=='!unwatch'):
            #stop watching one/all repository
            self.unwatch_command(email, repo)
        else:
            #Display usage if unkown command
            usage = "Watch command:\n"
            usage += "    !watch  %repo_name%    -> start watching this repository\n"
            usage += "Unmute command:\n"
            usage += "    !unmute    -> unmute notifications about all previously watched repositories\n"
            usage += "    !unmute %repo_name%     -> unmute notifications about this repository or start watching it\n"
            usage += "Mute command:\n"
            usage += "    !mute     -> mute notifications about all watched repositories\n"
            usage += "    !mute %RepoName%    -> mute notifications about this repository\n"
            
            xmpp.send_message(message.sender, "Unknown command: " + command + "\n" + usage)
    def post(self):

        message = xmpp.Message(self.request.POST)

        #DEBUG: log xmmp input
        log_xmpp_in = db.xmpp_in(From=message.sender)
        log_xmpp_in.Body = message.body
        log_xmpp_in.When = datetime.datetime.now()
        log_xmpp_in.put()

        #Split message body into args array
        args = message.body.split(" ")
        command = args[0]

        #try to read parameters ?
        try:
            repo = args[1]
        except IndexError:
            repo = ""

        #Parse sender JID to extract email
        email_pattern = re.compile('([\w\-\.]+@(\w[\w\-]+\.)+[\w\-]+)')
        result = email_pattern.match(message.sender)
        email = result.group(0)

        if (command == '!mute'):
            #mute (or stop watching) all or one repository
            self.mute_command(email, repo)
        elif (command == '!unmute'):
            #unmute (or start watching) all or one repository
            self.unmute_command(email, repo)
        elif (command == '!watch'):
            #start watching one repository
            self.watch_command(email, repo)
        elif (command == '!unwatch'):
            #stop watching one/all repository
            self.unwatch_command(email, repo)
        else:
            #Display usage if unkown command
            usage = "Watch command:\n"
            usage += "    !watch  %repo_name%    -> start watching this repository\n"
            usage += "Unmute command:\n"
            usage += "    !unmute    -> unmute notifications about all previously watched repositories\n"
            usage += "    !unmute %repo_name%     -> unmute notifications about this repository or start watching it\n"
            usage += "Mute command:\n"
            usage += "    !mute     -> mute notifications about all watched repositories\n"
            usage += "    !mute %RepoName%    -> mute notifications about this repository\n"

            xmpp.send_message(message.sender,
                              "Unknown command: " + command + "\n" + usage)
Exemple #10
0
    def handle_github_json(self, project, githubjson):

        repo_name = githubjson['repository']['name']
        repo_url = githubjson['repository']['url']
        pusher = githubjson['pusher']['name']

        commits = githubjson['commits']

        #prepare message string for xmpp
        message = "*" + pusher + "*" + " a push sur " + repo_url + " !\n"

        for commit in commits:

            dbcommit = db.commits(CommitId=commit['id'], ProjectId=project)
            dbcommit.Pusher = pusher
            dbcommit.ProjectId = project
            dbcommit.CommitId = commit['id']
            dbcommit.CommitUrl = commit['url']
            dbcommit.RepoName = repo_name
            dbcommit.RepoUrl = repo_url
            dbcommit.RepoShortenUrl = Util.shorten(repo_url)
            dbcommit.CommiterName = commit['author']['name']
            dbcommit.CommiterMail = commit['author']['email']
            dbcommit.CommitShortenUrl = Util.shorten(commit['url'])
            dbcommit.Message = commit['message']
            dbcommit.Timestamp = commit['timestamp']

            #insert commit infos into database
            dbcommit.put()

            message = message + dbcommit.CommitShortenUrl + ': ' + dbcommit.Message + '\n'

            for added in commit['added']:
                message = message + "+ " + added + '\n'

            for deleted in commit['removed']:
                message = message + "- " + deleted + '\n'

        #get subscribers and send them a xmpp notification
        subscribtions = db.subscribtions.gql(
            "WHERE Enabled = True AND RepoName = :1", repo_name)

        #prepare JIDs to send notification on
        for subscribtion in subscribtions:
            xmpp.send_message(subscribtion.Mail, message)
    def handle_github_json(self, project, githubjson):

        repo_name = githubjson['repository']['name']
        repo_url = githubjson['repository']['url']
        pusher = githubjson['pusher']['name']
        
        commits = githubjson['commits']
                
        #prepare message string for xmpp
        message = "*" + pusher + "*" + " a push sur " + repo_url + " !\n"
        
        for commit in commits:
            
            
            dbcommit = db.commits(CommitId = commit['id'], ProjectId = project)
            dbcommit.Pusher = pusher
            dbcommit.ProjectId = project
            dbcommit.CommitId = commit['id']
            dbcommit.CommitUrl = commit['url']
            dbcommit.RepoName =  repo_name
            dbcommit.RepoUrl =  repo_url
            dbcommit.RepoShortenUrl =  Util.shorten(repo_url)
            dbcommit.CommiterName =  commit['author']['name']
            dbcommit.CommiterMail =  commit['author']['email']
            dbcommit.CommitShortenUrl = Util.shorten(commit['url'])
            dbcommit.Message = commit['message']
            dbcommit.Timestamp = commit['timestamp']
            
            #insert commit infos into database
            dbcommit.put()
            
            message = message + dbcommit.CommitShortenUrl + ': '+ dbcommit.Message + '\n'
                
            for added in commit['added']:
                message = message + "+ " + added + '\n'
                
            for deleted in commit['removed']:
                message = message + "- " + deleted + '\n'
       
        #get subscribers and send them a xmpp notification
        subscribtions = db.subscribtions.gql("WHERE Enabled = True AND RepoName = :1", repo_name)        

        #prepare JIDs to send notification on
        for subscribtion in subscribtions:
            xmpp.send_message(subscribtion.Mail, message)
    def post(self):        
        
        
        
        payload = self.request.get('payload')
        
        #log les envois post json
        json_log = db.github_in()
        json_log.When = datetime.datetime.now()
        json_log.Body = payload
        json_log.put()
        
        
        
        # Charge le JSON envoye par github
        githubJson = json.loads(payload)
        
        
        repo_name = githubJson['repository']['name']
        repo_url = githubJson['repository']['url']
        pusher = githubJson['pusher']['name']
        
        commits = githubJson['commits']
                
        message = "*" + pusher + "*" + " a push sur " + repo_url + " !\n"
        
        for commit in commits:
            
            message = message + Util.shorten(commit['url']) + ': '+ commit['message'] + '\n'
                
            for added in commit['added']:
                message = message + "+ " + added + '\n'
                
            for deleted in commit['removed']:
                message = message + "- " + deleted + '\n'
                

        devs = db.developpers.gql("WHERE Active = True")        

        # Recupere le mail de chaque developpeur "actif"
        for dev in devs:
            xmpp.send_message(dev.Mail, message)
Exemple #13
0
    def post(self):

        payload = self.request.get('payload')

        #log les envois post json
        json_log = db.github_in()
        json_log.When = datetime.datetime.now()
        json_log.Body = payload
        json_log.put()

        # Charge le JSON envoye par github
        githubJson = json.loads(payload)

        repo_name = githubJson['repository']['name']
        repo_url = githubJson['repository']['url']
        pusher = githubJson['pusher']['name']

        commits = githubJson['commits']

        message = "*" + pusher + "*" + " a push sur " + repo_url + " !\n"

        for commit in commits:

            message = message + Util.shorten(
                commit['url']) + ': ' + commit['message'] + '\n'

            for added in commit['added']:
                message = message + "+ " + added + '\n'

            for deleted in commit['removed']:
                message = message + "- " + deleted + '\n'

        devs = db.developpers.gql("WHERE Active = True")

        # Recupere le mail de chaque developpeur "actif"
        for dev in devs:
            xmpp.send_message(dev.Mail, message)
Exemple #14
0
    def __init__(self):
        # base constructor
        super(Application, self).__init__(sys.argv)

        # make settings object, read existing settings
        # FIXME only tested on Linux
        self.settings = QtCore.QSettings(
            os.getenv('HOME') + '/.sacredbrowserrc',
            QtCore.QSettings.IniFormat)

        # prepare database access (does not do anything)
        self.connection = DbConnection.DbConnection(self)
        self.dbModel = DbModel.DbModel(self)
        self.collectionModel = CollectionModel.CollectionModel(self)

        # current database and collection (as pymongo objects)
        self.currentDatabase = None
        self.currentRunCollection = None

        # create main window
        self.mainWin = MainWin.MainWin(self)
        self.mainWin.show()

        # create non-modal sort dialog
        self.sortDialog = SortDialog.SortDialog()
        self.sortDialog.closeCalled.connect(self.slotSortDialogClosed)

        # connect signals/slots from main window
        self.mainWin.dbTree.activated.connect(self.slotChooseCollection)
        self.mainWin.connectToDb.clicked.connect(
            self.slotConnectToMongoDbInstance)

        # subwidgets in the main window
        self.mainWin.fieldChoice.fieldChoiceChanged.connect(
            self.collectionModel.slotFieldSelectionChanged)
        self.mainWin.quickDelete.stateChanged.connect(
            self.collectionModel.slotAllowQuickDeleteToggled)
        self.sortDialog.sortOrderChanged.connect(
            self.collectionModel.slotSortOrderChanged)
        self.mainWin.filterChoice.doNewSearch.connect(
            self.collectionModel.slotDoNewSearch)

        # display settings and controls
        self.mainWin.resultViewGroup.buttonClicked[int].connect(
            self.collectionModel.slotResultViewChanged)
        self.mainWin.sortButton.toggled.connect(self.slotSortDialogToggled)
        self.mainWin.deleteButton.clicked.connect(
            self.collectionModel.slotDeleteSelection)
        self.mainWin.copyButton.clicked.connect(
            self.collectionModel.slotCopyToClipboard)
        self.mainWin.fullEntryButton.clicked.connect(
            self.collectionModel.slotFullEntry)
        self.mainWin.collectionView.horizontalHeader().sectionResized.connect(
            self.collectionModel.slotSectionResized)
        self.mainWin.resetColWidthButton.clicked.connect(
            self.collectionModel.slotResetColWidth)

        self.aboutToQuit.connect(self.finalCleanup)

        # set initial values for check boxes
        quickDeleteChecked = self.settings.value('Global/quickDeleteChecked')
        if quickDeleteChecked.isValid():
            self.mainWin.quickDelete.setChecked(quickDeleteChecked.toBool())

        self.mainWin.resultViewRaw.setChecked(True)
        self.mainWin.resultViewRounded.setChecked(False)
        self.mainWin.resultViewPercent.setChecked(False)

        self.showStatusMessage('Welcome to SacredAdmin!')
 def watch_command(self, email, repo):
       
     db.enable_subscription(email, repo)
     message = "You subscribed to the " + repo + " repository !"
     
     xmpp.send_message(email, message)
    def watch_command(self, email, repo):

        db.enable_subscription(email, repo)
        message = "You subscribed to the " + repo + " repository !"

        xmpp.send_message(email, message)