Commit a4acfeca authored by Lucas Moura's avatar Lucas Moura

Merge tag 'upstream/0.7.1'

Upstream version 0.7.1

# gpg: Signature made Sun 07 Aug 2016 09:12:37 PM BRT using RSA key ID 2DA5B48C
# gpg: Good signature from "Lucas Albuquerque Medeiros de Moura <lucas.moura128@gmail.com>"
parents 4ec4bb50 4eb13cfe
......@@ -6,7 +6,8 @@ from apprecommender.main.app_recommender import AppRecommender
from apprecommender.config import Config
from apprecommender.initialize import Initialize
from apprecommender.strategy import (MachineLearning, MachineLearningBVA,
MachineLearningBOW)
MachineLearningBOW,
MachineLearningTrainError)
from apprecommender.main import collect_user_data
from apprecommender.main.options import get_parser
......@@ -14,6 +15,7 @@ SUCCESS = 0
ERROR_INIT = 1
ERROR_TRAIN = 2
PERMISSION_DENIED = 3
ERROR_INIT_TRAIN = 4
def parse_options(args, config):
......@@ -64,6 +66,8 @@ def run(args):
MachineLearning.train(MachineLearningBOW)
except IOError:
return PERMISSION_DENIED
except MachineLearningTrainError:
return ERROR_INIT_TRAIN
return SUCCESS
elif args['contribute']:
......@@ -91,6 +95,9 @@ def main():
print "Run: apprec.py --train"
elif result is PERMISSION_DENIED:
print "Please, run this command as sudo"
elif result is ERROR_INIT_TRAIN:
print 'Error: You need install more packages to use machine' \
' learning recommendations'
if __name__ == '__main__':
main()
......@@ -161,6 +161,15 @@ class PackageReference(ContentBased):
return result
class MachineLearningTrainError(Exception):
def __init__(self, value=''):
self.value = value
def __str__(self):
return repr(self.value)
class MachineLearning(ContentBased):
__metaclass__ = ABCMeta
......@@ -284,7 +293,10 @@ class MachineLearning(ContentBased):
try:
MachineLearning.PKGS_CLASSIFICATIONS = ml_data.create_data(
labels)
cls.run_train(MachineLearning.PKGS_CLASSIFICATIONS)
if len(MachineLearning.PKGS_CLASSIFICATIONS) > 0:
cls.run_train(MachineLearning.PKGS_CLASSIFICATIONS)
else:
raise MachineLearningTrainError()
except IOError:
raise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment