Add core-office ping-install command, for DB setup
				
					
				
			This commit is contained in:
		
							parent
							
								
									13e5f2a801
								
							
						
					
					
						commit
						bde8200cdf
					
				
					 2 changed files with 28 additions and 0 deletions
				
			
		|  | @ -26,10 +26,14 @@ CORE Office commands | |||
| 
 | ||||
| import sys | ||||
| 
 | ||||
| import requests | ||||
| from requests.auth import HTTPDigestAuth | ||||
| 
 | ||||
| from rattail import commands | ||||
| from rattail_corepos import __version__ | ||||
| from rattail.util import load_object | ||||
| from rattail_corepos.corepos.office.util import get_fannie_config_value | ||||
| from rattail_corepos.config import core_office_url | ||||
| 
 | ||||
| 
 | ||||
| def main(*args): | ||||
|  | @ -129,3 +133,26 @@ class ImportSelf(commands.ImportSubcommand): | |||
|     name = 'import-self' | ||||
|     description = __doc__.strip() | ||||
|     handler_key = 'to_self.from_corepos_db_office_op.import' | ||||
| 
 | ||||
| 
 | ||||
| class PingInstall(commands.Subcommand): | ||||
|     """ | ||||
|     Ping the /install URL in CORE Office (for DB setup) | ||||
|     """ | ||||
|     name = 'ping-install' | ||||
|     description = __doc__.strip() | ||||
| 
 | ||||
|     def run(self, args): | ||||
|         url = core_office_url(self.config, require=True) | ||||
|         url = f'{url}/install/' | ||||
| 
 | ||||
|         # TODO: hacky re-using credentials from API config.. | ||||
|         username = self.config.get('corepos.api', 'htdigest.username') | ||||
|         password = self.config.get('corepos.api', 'htdigest.password') | ||||
| 
 | ||||
|         session = requests.Session() | ||||
|         if username and password: | ||||
|             session.auth = HTTPDigestAuth(username, password) | ||||
| 
 | ||||
|         response = session.get(url) | ||||
|         response.raise_for_status() | ||||
|  |  | |||
|  | @ -45,6 +45,7 @@ core_office.commands = | |||
|         import-csv = rattail_corepos.corepos.office.commands:ImportCSV | ||||
|         import-self = rattail_corepos.corepos.office.commands:ImportSelf | ||||
|         get-config-value = rattail_corepos.corepos.office.commands:GetConfigValue | ||||
|         ping-install = rattail_corepos.corepos.office.commands:PingInstall | ||||
| 
 | ||||
| crepes.commands = | ||||
|         export-core = rattail_corepos.corepos.commands:ExportCore | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar