Esempio n. 1
0
def main():
    def progressHandler(prestaProgressEvent):
        if prestaProgressEvent.is_finished:
            print('%s' % prestaProgressEvent.msg)
        else:
            print('%i/%i - %s' %
                  (prestaProgressEvent.current_step,
                   prestaProgressEvent.max_step, prestaProgressEvent.msg))

# A CachedPrestaHelper is a PrestaHelper with cache capabilities

    cachedphelper = CachedPrestaHelper(config.presta_api_url,
                                       config.presta_api_key,
                                       debug=False,
                                       progressCallback=progressHandler)
    # Force loading cache
    #   cachedphelper.load_from_webshop()

    #tester = CachedPrestaHelperTest( cachedphelper )
    #tester.test_cache()
    print('******************************************************************')
    print('*  Cache statistics                                              *')
    print('******************************************************************')
    print('Type of Helper is %s' % type(cachedphelper))
    print('#Carriers = %s' % len(cachedphelper.carriers))
    print('#OrderStates = %s' % len(cachedphelper.order_states))
    print('#Products = %i' % len(cachedphelper.products))
    print('#suppliers = %i' % len(cachedphelper.suppliers))
    print('#categories = %i' % len(cachedphelper.categories))
    print('#stock availables = %i' % len(cachedphelper.stock_availables))

    #print('mise à jour des qty' )
    #cachedphelper.stock_availables.update_quantities()
    #print( 'Voila, c est fait' )

    print('******************************************************************')
    print('*  Derniers Messages client                                      *')
    print('******************************************************************')
    """ affiche les x derniers messages clients """
    id = cachedphelper.get_lastcustomermessage_id()
    print('last message id: %s' % id)
    custmsgs = cachedphelper.get_lastcustomermessages(id, 10)
    for custmsg in reversed(custmsgs):  # CustomerMessageData
        print('--- id: %s---------------' % custmsg.id)
        print('   date_add: %s' % custmsg.date_add)
        print('   read    : %s' % custmsg.read)
        print('   Employee: %s' % custmsg.id_employee)
        print('   id_customer_thread: %s' % custmsg.id_customer_thread)
        print(custmsg.message)
        print('')
    # Ensure cache file to be saved (and will be automatically reloaded)
    #cachedphelper.save_cache_file()

    # read char on keyboard
    print('Press a key to continue:')
    char = sys.stdin.read(1)
    return 0
Esempio n. 2
0
def main():
	def progressHandler( prestaProgressEvent ):
		if prestaProgressEvent.is_finished:
			print( '%s' %prestaProgressEvent.msg )
		else:
			print( '%i/%i - %s' % ( prestaProgressEvent.current_step, prestaProgressEvent.max_step, prestaProgressEvent.msg ) )
    
    # A CachedPrestaHelper is a PrestaHelper with cache capabilities	
	cachedphelper = CachedPrestaHelper( config.presta_api_url, config.presta_api_key, debug = False, progressCallback = progressHandler )
	# Force loading cache
	#   cachedphelper.load_from_webshop()
	
	#tester = CachedPrestaHelperTest( cachedphelper )
	#tester.test_cache()
	print( '******************************************************************' )
	print( '*  Cache statistics                                              *' )
	print( '******************************************************************' )
	print( 'Type of Helper is %s' % type(cachedphelper) )
	print( '#Carriers = %s' % len(cachedphelper.carriers) )
	print( '#OrderStates = %s' % len( cachedphelper.order_states ) )
	print( '#Products = %i' % len( cachedphelper.products ) )
	print( '#suppliers = %i' % len( cachedphelper.suppliers ) )
	print( '#categories = %i' % len( cachedphelper.categories ) )
	print( '#stock availables = %i' % len( cachedphelper.stock_availables ) )
			
	#print('mise à jour des qty' )
	#cachedphelper.stock_availables.update_quantities()
	#print( 'Voila, c est fait' )
		
	print( '******************************************************************' )
	print( '*  Derniers Messages client                                      *' )
	print( '******************************************************************' )
		
	""" affiche les x derniers messages clients """
	id = cachedphelper.get_lastcustomermessage_id()
	print( 'last message id: %s' % id )
	custmsgs = cachedphelper.get_lastcustomermessages( id, 10 )
	for custmsg in reversed(custmsgs): # CustomerMessageData
		print( '--- id: %s---------------' % custmsg.id )
		print( '   date_add: %s' % custmsg.date_add )
		print( '   read    : %s' % custmsg.read )
		print( '   Employee: %s' % custmsg.id_employee )
		print( '   id_customer_thread: %s' % custmsg.id_customer_thread )
		print( custmsg.message )
		print( '' )		
	# Ensure cache file to be saved (and will be automatically reloaded)
	#cachedphelper.save_cache_file()
	
	# read char on keyboard
        print( 'Press a key to continue:' ) 
	char = sys.stdin.read(1) 
	return 0