def testWorkingFolder(self): #test path is dir currentFile = inspect.currentframe().f_code.co_filename result, additional = svn.testWorkingFolder(currentFile, "http://atmind/svn/test") self.assertEqual(result, svn.SVNWORKINGFOLDERISFILE) #location does not exist result, additional = svn.testWorkingFolder("/bladiebla", "http://atmind/svn/test") self.assertEqual(result, svn.SVNNOWORKINGFOLDER) #non existing url result, additional = svn.testWorkingFolder("/tmp", "http://atmind2/svn/test") self.assertEqual(result, svn.SVNNOBINDING) #different svn, make test dir if os.path.exists("/tmp/test"): retcode = subprocess.call(["rm", "-Rf", "/tmp/test"]) svn.svnCheckout("/tmp/test", "http://atmind/svn/test", "test", "test") result, additional = svn.testWorkingFolder( "/tmp/test", "http://atmind/svn/yofrankie") self.assertEqual(result, svn.SVNURLDIFF) #same svn, make test dir if os.path.exists("/tmp/test"): retcode = subprocess.call(["rm", "-Rf", "/tmp/test"]) svn.svnCheckout("/tmp/test", "http://atmind/svn/test", "test", "test") result, additional = svn.testWorkingFolder("/tmp/test", "http://atmind/svn/test") self.assertEqual(result, svn.SVNURLSAME)
def handleAdd(wfile, request, session): productionName=request["production_name"] productionLocation=request["production_location"] productionSvnUrl=request["production_svnurl"] productionSvnUsername=request["production_svnusername"] productionSvnPassword=request["production_svnpassword"] try: if productionSvnUrl=="": if not path.isdir(productionLocation): wfile.write("[{\"error\":\"Location ["+productionLocation+"] does not exist or is not a directory\"}]\r\n".encode()); else: indexer.insertProduction(productionName, productionLocation); wfile.write("[]\r\n".encode()); else: result, additional = svn.testWorkingFolder(productionLocation, productionSvnUrl); if result in [svn.SVNNOBINDING, svn.SVNNOWORKINGFOLDER]: #ok, checkout needed do checkout svn.svnCheckout(productionLocation, productionSvnUrl, productionSvnUsername, productionSvnPassword); indexer.insertProduction(productionName, productionLocation, productionSvnUrl, productionSvnUsername, productionSvnPassword); wfile.write("[]\r\n".encode()); elif result in [svn.SVNURLSAME]: #ok, do nothing indexer.insertProduction(productionName, productionLocation, productionSvnUrl, productionSvnUsername, productionSvnPassword); wfile.write("[]\r\n".encode()); elif result in [svn.SVNURLDIFF]: #error, user entry wfile.write("[{\"error\":\"Location ["+productionLocation+"] contains content from a different SVN URL\"}]\r\n".encode()); elif result in [svn.SVNWORKINGFOLDERISFILE]: #error, user entry wfile.write("[{\"error\":\"Location ["+productionLocation+"] is a file\"}]\r\n".encode()); except svn.pysvn.ClientError as c: wfile.write("[{\"error\":\""+str(c)+"\"}]\r\n".encode());
def testWorkingFolder(self): #test path is dir currentFile = inspect.currentframe().f_code.co_filename; result, additional = svn.testWorkingFolder(currentFile, "http://atmind/svn/test"); self.assertEqual(result, svn.SVNWORKINGFOLDERISFILE); #location does not exist result, additional = svn.testWorkingFolder("/bladiebla", "http://atmind/svn/test"); self.assertEqual(result, svn.SVNNOWORKINGFOLDER); #non existing url result, additional = svn.testWorkingFolder("/tmp", "http://atmind2/svn/test"); self.assertEqual(result, svn.SVNNOBINDING); #different svn, make test dir if os.path.exists("/tmp/test"): retcode = subprocess.call(["rm", "-Rf", "/tmp/test"]); svn.svnCheckout("/tmp/test", "http://atmind/svn/test", "test", "test"); result, additional = svn.testWorkingFolder("/tmp/test", "http://atmind/svn/yofrankie"); self.assertEqual(result, svn.SVNURLDIFF); #same svn, make test dir if os.path.exists("/tmp/test"): retcode = subprocess.call(["rm", "-Rf", "/tmp/test"]); svn.svnCheckout("/tmp/test", "http://atmind/svn/test", "test", "test"); result, additional = svn.testWorkingFolder("/tmp/test", "http://atmind/svn/test"); self.assertEqual(result, svn.SVNURLSAME);
def handleAdd(wfile, request, session): productionName = request["production_name"] productionLocation = request["production_location"] productionSvnUrl = request["production_svnurl"] productionSvnUsername = request["production_svnusername"] productionSvnPassword = request["production_svnpassword"] try: if productionSvnUrl == "": if not path.isdir(productionLocation): wfile.write( "[{\"error\":\"Location [" + productionLocation + "] does not exist or is not a directory\"}]\r\n".encode()) else: indexer.insertProduction(productionName, productionLocation) wfile.write("[]\r\n".encode()) else: result, additional = svn.testWorkingFolder(productionLocation, productionSvnUrl) if result in [svn.SVNNOBINDING, svn.SVNNOWORKINGFOLDER]: #ok, checkout needed do checkout svn.svnCheckout(productionLocation, productionSvnUrl, productionSvnUsername, productionSvnPassword) indexer.insertProduction(productionName, productionLocation, productionSvnUrl, productionSvnUsername, productionSvnPassword) wfile.write("[]\r\n".encode()) elif result in [svn.SVNURLSAME]: #ok, do nothing indexer.insertProduction(productionName, productionLocation, productionSvnUrl, productionSvnUsername, productionSvnPassword) wfile.write("[]\r\n".encode()) elif result in [svn.SVNURLDIFF]: #error, user entry wfile.write( "[{\"error\":\"Location [" + productionLocation + "] contains content from a different SVN URL\"}]\r\n". encode()) elif result in [svn.SVNWORKINGFOLDERISFILE]: #error, user entry wfile.write("[{\"error\":\"Location [" + productionLocation + "] is a file\"}]\r\n".encode()) except svn.pysvn.ClientError as c: wfile.write("[{\"error\":\"" + str(c) + "\"}]\r\n".encode())