Skip to content

Commit

Permalink
Merge pull request #76 from Kyria/develop
Browse files Browse the repository at this point in the history
Update master with all updates
  • Loading branch information
Kyria authored Mar 7, 2020
2 parents 831b80d + 3708b0d commit a92d47d
Show file tree
Hide file tree
Showing 225 changed files with 22,617 additions and 13,259 deletions.
64 changes: 64 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
name: lb-docker-build

trigger:
batch: true
branches:
include:
- develop
- master
- refs/tags/*

pr:
branches:
include:
- develop
- master

pool:
vmImage: 'ubuntu-latest'

variables:
${{ if eq(variables['Build.SourceBranchName'], 'master') }}:
customTag: 'latest'
${{ if ne(variables['Build.SourceBranchName'], 'master') }}:
customTag: $(Build.SourceBranchName)

jobs:
- job: pullrequests
displayName: "Pull Request build test"
condition: eq(variables['Build.Reason'], 'PullRequest')
steps:
- task: Docker@2
displayName: Build LB image
inputs:
containerRegistry: 'dockerhub'
repository: 'anakhon/lazyblacksmith'
command: 'build'
Dockerfile: '**/Dockerfile'
arguments: '--rm'
addPipelineData: false
buildContext: $(Build.SourcesDirectory)

- job: BuildAndPushToDockerHub
displayName: 'Build and Push to Docker Hub'
condition: ne(variables['Build.Reason'], 'PullRequest')
steps:
- task: Docker@2
displayName: Login to Docker Registry
inputs:
command: login
containerRegistry: 'dockerhub'
- task: Docker@2
displayName: Build & Push LB image
inputs:
containerRegistry: 'dockerhub'
repository: 'anakhon/lazyblacksmith'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: $(customTag)
addPipelineData: false
buildContext: $(Build.SourcesDirectory)
37 changes: 37 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
__pycache__
*.pyc
*.pyo
*.pyd
*.log
.Python
env
venv
env3
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.log
.git
node_modules
.eslintrc.json
.gitattributes
.gitignore
.pylintrc
.vscode
tmp
*.sqlite

# celery stuff
celerybeat-schedule.db

# configs
config.py

# docker stuff...
Dockerfile
39 changes: 21 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
env_lnx/
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -69,21 +70,23 @@ lazyblacksmith/static/ccp/Types/
*.sublime-*
env3/
config_docker\.py

lazyblacksmith/static/css/bootstrap_lb\.css

lazyblacksmith/static/css/lb\.css

lazyblacksmith/static/css/lb\.min\.css

lazyblacksmith/static/css/lb\.min\.css\.map

lazyblacksmith/static/js/bootstrap\.js

lazyblacksmith/static/js/lb\.js

lazyblacksmith/static/js/lb\.min\.js

lazyblacksmith/static/js/lb\.min\.js\.map

\.vscode/

lazyblacksmith/static/css/bootstrap_lb\.css

lazyblacksmith/static/css/lb\.css

lazyblacksmith/static/css/lb\.min\.css

lazyblacksmith/static/css/lb\.min\.css\.map

lazyblacksmith/static/js/bootstrap\.js

lazyblacksmith/static/js/lb\.js

lazyblacksmith/static/js/lb\.min\.js

lazyblacksmith/static/js/lb\.min\.js\.map

\.vscode/
worker.pid
celerybeat-schedule.db
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 5 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[MASTER]
ignore=migrations
[TYPECHECK]
ignored-classes=scoped_session,SQLAlchemy,alembic,alembic.op
ignored-classes=scoped_session,SQLAlchemy,alembic,alembic.op
[MESSAGES CONTROL]
disable=C0103,R0201,R0903,no-member
118 changes: 4 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,130 +4,20 @@

An EVE Online Industry application for lazy people.


## About
LazyBlacksmith is a flask application allowing people to get informations about industry in eveonline.

#### Features
## Features
* Blueprints
* Manufacturing informations including components required and installation costs
* Research data for material and time efficiency (time, cost)
* Invention informations for components and costs.
* Reaction informations for components and costs.
* Get and compare item price over all regions

#### CREST (as batch or through celery)
* Use CREST market price / adjusted price for costs
* Use CREST industry index for installation fee

#### TODO
* Ore refining and compression (see branch ore_refining_compression)
* View refining table
* Calculate compression from user needs (in materials) and using defaults ore
* Also allow to manually select what ore we want to use to compress
* Permalinks in manufacturing / research / production
* Link API key to user account (CREST Login) to get, save and configure existing blueprints, with their ME/TE for direct use in manufacturing / invention



## Requirements
* Python 2.7
* Virtualenv (recommended)
* [NodeJS](http://nodejs.org/) + [Grunt-CLI](http://gruntjs.com/getting-started)
* Database connectors depending on the one you use (MySQL 5.6+,...)
* See [requirements.txt](requirements/) for other requirements
* (Optional/Recommended) Cache system (eg. python-memcached or redis-cache)
* (Optional) [Redis](http://redis.io/) for async tasks and queues (and cache)!
* Eve Online Icons (see CCP Icons part)



## Installation

#### Environnement
Create your virtualenv and get LazyBlacksmith.
```shell
git clone https://github.com/Kyria/LazyBlacksmith.git
cd LazyBlacksmith
virtualenv env
```

Once your virtualenv is created, load it and install requirements
```
# in windows, type env/Script/activate
source env/bin/activate
pip install -r requirements/requirements.txt
# if you are using celery with redis
pip install -r requirements/requirements-celery-redis.txt
```

#### Configs
You now need to create an application on [EVE Online Developpers](https://developers.eveonline.com/applications) to get CREST informations (secret key, client ID)

Once this is done, copy config.dist into config.py and edit the file.
Some mandatory informations :
```
DEBUG : True for dev, False for prod (require static compilation, see below)
SQLALCHEMY_DATABASE_URI : the database informations
USE_CCP_ICONS : True/False to display icons (read the CCP Icons chapter below)
CACHE_TYPE : leave 'null' if no cache, or set it your needs
Celery configs, if you don't use it, leave them like that
CREST API informations : set it with what you got/set before in CCP Developpers Application
```

#### Init data
Now you set everything, it's time to "install" the database. This should create all the table in your database (if you get any errors, check you sqlalchemy informations)
```
python manage.py db upgrade
```

Download the latest SDE conversion from fuzzwork in sqlite [here](https://www.fuzzwork.co.uk/dump/sqlite-latest.sqlite.bz2) unzip it then load it with :
```
python manage.py sde_import -d path/to/sqlite-latest.sqlite
```

If you also want to have some CREST data right now, you can run the following commands :
```
python manage.py celery_task -a update_adjusted_price
python manage.py celery_task -a update_industry_index
python manage.py celery_task -a update_market_price
```

#### Static file compilation
If you are using it in production environnement, or upgrading your installation, you need to remake all static files (css/js). For this, first do ```npm install``` to install all the nodejs required package, then type ```grunt``` to compile the static files.

#### CREST / API
To update the CREST data, you have 2 solutions :
* run them directly, as you did in the "init data" part
* use celery

##### Celery + Celery Beat (Scheduler)
There are multiple solution to run celery with celery beat. The example below are the minimal configurations.

You can celery with the -B option, to run beat and worker in the same time :
```
PATH/TO/LazyBlacksmith/env/bin/celery worker -A celery_app:celery_app -B -c5
```

Or you can run two daemons, one for celery beat, the other for the workers :
```
# celery beat
PATH/TO/LazyBlacksmith/env/bin/celery beat -A celery_app:celery_app
# celery workers
PATH/TO/LazyBlacksmith/env/bin/celery multi start worker -A celery_app:celery_app -c5
```



## CCP Icons

If you set ```USE_CCP_ICONS = True``` you need to download the files "EVE_VERSION_Types.zip" from CCP Toolkit ; https://developers.eveonline.com/resource/resources and then
move the files into ```lazyblacksmith/static/ccp/``` (as a result, you should have ```lazyblacksmith/static/ccp/Types/files.png```)

## Documentation

[See here for the docs](https://kyria.github.io/LazyBlacksmith/)

## Contact
Guillaume B.
Expand Down
41 changes: 41 additions & 0 deletions app_celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- encoding: utf-8 -*-
# pylint: disable=unused-import
# flake8: noqa
from __future__ import absolute_import
import logging

import config

from lbtasks.flask_celery import celery_app
from lbtasks.task_app import create_app
from celery.schedules import crontab

# disable / enable loggers we want
logging.getLogger('pyswagger').setLevel(logging.ERROR)
logging.getLogger('lb.tasks').setLevel(logging.WARNING)

celery_app.init_app(create_app(config))
celery_app.autodiscover_tasks(packages=['lbtasks'])
celery_app.conf.beat_schedule = {
'purge': {
'task': 'schedule.purge',
'schedule': crontab(minute=0, hour=1),
},
'spawn_char_tasks': {
'task': 'schedule.character_task_spawner',
'schedule': crontab(minute='*/5'),
},
'update_indexes': {
'task': 'universe.industry_indexes',
'schedule': crontab(minute=0, hour=0),
},
'update_adjusted_price': {
'task': 'universe.adjusted_price',
'schedule': crontab(minute=0, hour=0),
},
'update_market_order': {
'task': 'universe.spawn_market_price_tasks',
'schedule': crontab(minute='*/30'),
},
}
celery_app.conf.timezone = 'UTC'
1 change: 0 additions & 1 deletion bootstrap
Submodule bootstrap deleted from 779ad9
40 changes: 0 additions & 40 deletions celery_app.py

This file was deleted.

Loading

0 comments on commit a92d47d

Please sign in to comment.