Skip to content

Commit

Permalink
Set version to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnitsch committed Oct 4, 2020
1 parent 9410a5e commit ce37aa5
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 172 deletions.
204 changes: 102 additions & 102 deletions client/setup.py
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
import codecs
import os.path
import pathlib
from setuptools import setup, find_packages

def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()

def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")

here = pathlib.Path(__file__).parent.resolve()

long_description = (here / 'README.md').read_text(encoding='utf-8')

setup(
name='upload-tm-records',
# https://www.python.org/dev/peps/pep-0440/
version=get_version('src/upload_tm_records.py'),
description='Upload your trackmania records to a trackmania-records server!',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/rsnitsch/trackmania-records',
author='Robert Nitsch',
author_email='mail@robertnitsch.de',
# For a list of valid classifiers, see https://pypi.org/classifiers/
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Topic :: Games/Entertainment',

# Specify the Python versions you support here. In particular, ensure
# that you indicate you support Python 3. These classifiers are *not*
# checked by 'pip install'. See instead 'python_requires' below.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only',
],

# This field adds keywords for your project which will appear on the
# project page. What does your project relate to?
#
# Note that this is a list of additional keywords, separated
# by commas, to be used to assist searching for the distribution in a
# larger catalog.
keywords='trackmania, gaming', # Optional

package_dir={'': 'src'},

# You can just specify package directories manually here if your project is
# simple. Or you can use find_packages().
#
# Alternatively, if you just want to distribute a single Python file, use
# the `py_modules` argument instead as follows, which will expect a file
# called `my_module.py` to exist:
#
py_modules=["upload_tm_records"],
#
#packages=find_packages(where='src'), # Required

# Specify which Python versions you support. In contrast to the
# 'Programming Language' classifiers above, 'pip install' will check this
# and refuse to install the project if the version does not match. See
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
python_requires='>=3.7, <4',

# This field lists other packages that your project depends on to run.
# Any package you put here will be installed by pip when your project is
# installed, so they must be valid existing projects.
#
# For an analysis of "install_requires" vs pip's requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['requests'], # Optional

# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# `pip` to create the appropriate form of executable for the target
# platform.
#
# For example, the following would provide a command called `sample` which
# executes the function `main` from this package when invoked:
entry_points={ # Optional
'console_scripts': [
'upload-tm-records=upload_tm_records:main',
],
},

project_urls={ # Optional
'Bug Reports': 'https://github.com/rsnitsch/trackmania-records/issues',
'Source': 'https://github.com/rsnitsch/trackmania-records',
},
)
import codecs
import os.path
import pathlib
from setuptools import setup, find_packages

def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()

def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")

here = pathlib.Path(__file__).parent.resolve()

long_description = (here / 'README.md').read_text(encoding='utf-8')

setup(
name='upload-tm-records',
# https://www.python.org/dev/peps/pep-0440/
version=get_version('src/upload_tm_records.py'),
description='Upload your trackmania records to a trackmania-records server!',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/rsnitsch/trackmania-records',
author='Robert Nitsch',
author_email='mail@robertnitsch.de',
# For a list of valid classifiers, see https://pypi.org/classifiers/
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Topic :: Games/Entertainment',

# Specify the Python versions you support here. In particular, ensure
# that you indicate you support Python 3. These classifiers are *not*
# checked by 'pip install'. See instead 'python_requires' below.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only',
],

# This field adds keywords for your project which will appear on the
# project page. What does your project relate to?
#
# Note that this is a list of additional keywords, separated
# by commas, to be used to assist searching for the distribution in a
# larger catalog.
keywords='trackmania, gaming', # Optional

package_dir={'': 'src'},

# You can just specify package directories manually here if your project is
# simple. Or you can use find_packages().
#
# Alternatively, if you just want to distribute a single Python file, use
# the `py_modules` argument instead as follows, which will expect a file
# called `my_module.py` to exist:
#
py_modules=["upload_tm_records"],
#
#packages=find_packages(where='src'), # Required

# Specify which Python versions you support. In contrast to the
# 'Programming Language' classifiers above, 'pip install' will check this
# and refuse to install the project if the version does not match. See
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
python_requires='>=3.7, <4',

# This field lists other packages that your project depends on to run.
# Any package you put here will be installed by pip when your project is
# installed, so they must be valid existing projects.
#
# For an analysis of "install_requires" vs pip's requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['requests'], # Optional

# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# `pip` to create the appropriate form of executable for the target
# platform.
#
# For example, the following would provide a command called `sample` which
# executes the function `main` from this package when invoked:
entry_points={ # Optional
'console_scripts': [
'upload-tm-records=upload_tm_records:main',
],
},

project_urls={ # Optional
'Bug Reports': 'https://github.com/rsnitsch/trackmania-records/issues',
'Source': 'https://github.com/rsnitsch/trackmania-records',
},
)
2 changes: 1 addition & 1 deletion client/src/upload_tm_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import requests

__version__ = '1.0.0b1'
__version__ = '1.0.0'

logger = logging.getLogger(__name__)

Expand Down
138 changes: 69 additions & 69 deletions server/html/upload.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
<?php
if (!isset($_POST['records'])) {
http_response_code(400);
die("No records");
}

if (!isset($_POST['client_name'])) {
http_response_code(400);
die("No client_name");
}

if (!isset($_POST['client_version'])) {
http_response_code(400);
die("No client_version");
}

define('REQUIRED_CLIENT_VERSION', '1.0.0b1');
if ($_POST['client_version'] !== REQUIRED_CLIENT_VERSION) {
http_response_code(400);
die("Your client is outdated. Please use version ".REQUIRED_CLIENT_VERSION);
}

//file_put_contents('debug.log', print_r($_POST, true));
$json = $_POST['records'];
$records = json_decode($json, true);
//print_r($records);

try {
$pdo = new \PDO("sqlite:database.db");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$commands = ['CREATE TABLE IF NOT EXISTS records (
game TEXT NOT NULL,
user TEXT NOT NULL,
track TEXT NOT NULL,
best INTEGER NOT NULL,
PRIMARY KEY (game, user, track)
)'];

foreach ($commands as $command) {
$pdo->exec($command);
}

foreach ($records as $record) {
//print_r($record);

$user = $record['user'];
$track = $record['track'];
$best = intval($record['best']);

// Delete previous record.
$st = $pdo->prepare('DELETE FROM records WHERE user = :user AND track = :track');
$st->bindParam(':user', $user, PDO::PARAM_STR);
$st->bindParam(':track', $track, PDO::PARAM_STR);
$st->execute();

// Add new record.
$st = $pdo->prepare("INSERT INTO records (game, user, track, best) VALUES ('Trackmania 2020', :user, :track, :best)");
$st->bindParam(':user', $user, PDO::PARAM_STR);
$st->bindParam(':track', $track, PDO::PARAM_STR);
$st->bindParam(':best', $best, PDO::PARAM_INT);
$st->execute();
}

echo "Success!";
} catch (PDOException $e) {
http_response_code(500);
die('Database error: '.$e->getMessage());
}
<?php
if (!isset($_POST['records'])) {
http_response_code(400);
die("No records");
}

if (!isset($_POST['client_name'])) {
http_response_code(400);
die("No client_name");
}

if (!isset($_POST['client_version'])) {
http_response_code(400);
die("No client_version");
}

define('REQUIRED_CLIENT_VERSION', '1.0.0');
if ($_POST['client_version'] !== REQUIRED_CLIENT_VERSION) {
http_response_code(400);
die("Your client is outdated. Please use version ".REQUIRED_CLIENT_VERSION);
}

//file_put_contents('debug.log', print_r($_POST, true));
$json = $_POST['records'];
$records = json_decode($json, true);
//print_r($records);

try {
$pdo = new \PDO("sqlite:database.db");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$commands = ['CREATE TABLE IF NOT EXISTS records (
game TEXT NOT NULL,
user TEXT NOT NULL,
track TEXT NOT NULL,
best INTEGER NOT NULL,
PRIMARY KEY (game, user, track)
)'];

foreach ($commands as $command) {
$pdo->exec($command);
}

foreach ($records as $record) {
//print_r($record);

$user = $record['user'];
$track = $record['track'];
$best = intval($record['best']);

// Delete previous record.
$st = $pdo->prepare('DELETE FROM records WHERE user = :user AND track = :track');
$st->bindParam(':user', $user, PDO::PARAM_STR);
$st->bindParam(':track', $track, PDO::PARAM_STR);
$st->execute();

// Add new record.
$st = $pdo->prepare("INSERT INTO records (game, user, track, best) VALUES ('Trackmania 2020', :user, :track, :best)");
$st->bindParam(':user', $user, PDO::PARAM_STR);
$st->bindParam(':track', $track, PDO::PARAM_STR);
$st->bindParam(':best', $best, PDO::PARAM_INT);
$st->execute();
}

echo "Success!";
} catch (PDOException $e) {
http_response_code(500);
die('Database error: '.$e->getMessage());
}

0 comments on commit ce37aa5

Please sign in to comment.