def test_portable_path(self):
     """ Testing if paths are generated appropiately. """
     storage.setup()
     self.assertEquals(storage.app_type, "portable")
     self.assertTrue(os.path.exists(storage.data_directory))
     self.assertEquals(storage.data_directory,
                       os.path.join(paths.app_path(), "data"))
	def test_installer_path(self):
		""" Testing if paths are generated appropiately. """
		# this is a temporary fix for winpaths.
		fake_installer_file = open(os.path.join(paths.app_path(), "uninstall.exe"), "w")
		fake_installer_file.close()
		fix_winpaths.fix()
		storage.setup()
		self.assertEquals(storage.app_type, "installed")
		self.assertTrue(os.path.exists(storage.data_directory))
		self.assertEquals(storage.data_directory, paths.app_data_path("musicDL"))
 def test_installer_path(self):
     """ Testing if paths are generated appropiately. """
     # this is a temporary fix for winpaths.
     fake_installer_file = open(
         os.path.join(paths.app_path(), "Uninstall.exe"), "w")
     fake_installer_file.close()
     fix_winpaths.fix()
     storage.setup()
     self.assertEquals(storage.app_type, "installed")
     self.assertTrue(os.path.exists(storage.data_directory))
     self.assertEquals(storage.data_directory, paths.data_path("musicDL"))
	def test_portable_path(self):
		""" Testing if paths are generated appropiately. """
		storage.setup()
		self.assertEquals(storage.app_type, "portable")
		self.assertTrue(os.path.exists(storage.data_directory))
		self.assertEquals(storage.data_directory, os.path.join(paths.app_path(), "data"))
Exemple #5
0
def get_unicorn(unicorn_id):
    unicorn = storage.fetch_unicorn(unicorn_id);
    if unicorn is not None:
        return jsonify(unicorn.toDict())
    else:
        return '', 404

def update_unicorn(unicorn):
    json_data = request.get_json()
    unicorn = Unicorn()
    unicorn.fromJSON(json_data)
    
    if storage.update_unicorn(unicorn):
        # 204, unicorn updated
        return '', 204
    else:
        # 400, couldn't update unicorn
        return '', 400

def delete_unicorn(unicorn):
    if storage.delete_unicorn(unicorn):
        # 204, unicorn deleted
        return '', 204
    else:
        # 404, unicorn not found
        return '', 404

# Set up the database
storage.setup()
Exemple #6
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals    # at top of module
# this is the first fix we have to import just before the paths module would.
# it changes a call from wintypes to ctypes.
from fixes import fix_winpaths
fix_winpaths.fix()
import os
import logging
import storage
import traceback
import sys
storage.setup()
# Let's import config module here as it is dependent on storage being setup.
import config
logging.basicConfig(filename=os.path.join(storage.data_directory, "info.log"), level=logging.DEBUG, filemode="w")
# Let's mute the google discovery_cache logger as we won't use it and we'll avoid some tracebacks.
glog = logging.getLogger("googleapiclient.discovery_cache")
glog.setLevel(logging.CRITICAL)
# Let's capture all exceptions raised in our log file (especially useful for pyinstaller builds).
sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
log = logging.getLogger("main")
log.debug("Logger initialized. Saving debug to {0}".format(storage.data_directory,))
log.debug("Using Python version {0}".format(sys.version,))
if sys.version[0] == "2":
	if hasattr(sys, "frozen"):
		log.debug("Applying fixes for Python 2 frozen executables.")
		import fixes
		fixes.setup()
import i18n
i18n.setup()
config.setup()