Skip to content

Commit

Permalink
- Drop Python 2 support and only support 3.6+
Browse files Browse the repository at this point in the history
- Update contact info
  • Loading branch information
WinterPhoenix committed Sep 13, 2024
1 parent bbd315d commit 6f97b3a
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 106 deletions.
12 changes: 4 additions & 8 deletions recipes/3.WalletBalance/wallet_webauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
from getpass import getpass
import steam.webauth as wa

try:
user_input = raw_input
except NameError:
user_input = input

username = user_input("Username: ")
username = input("Username: ")
password = getpass("Password: ")

webclient = wa.WebAuth(username, password)
Expand All @@ -16,11 +12,11 @@
webclient.login()
except wa.CaptchaRequired:
print("Captcha:" + webclient.captcha_url)
webclient.login(captcha=user_input("Captcha code: "))
webclient.login(captcha=input("Captcha code: "))
except wa.EmailCodeRequired:
webclient.login(email_code=user_input("Email code: "))
webclient.login(email_code=input("Email code: "))
except wa.TwoFactorCodeRequired:
webclient.login(twofactor_code=user_input("2FA code: "))
webclient.login(twofactor_code=input("2FA code: "))

if webclient.complete:
resp = webclient.session.get('https://store.steampowered.com/account/store_transactions/')
Expand Down
16 changes: 6 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@
__version__ = f.readline().split('"')[1]

install_requires = [
'six>=1.10',
'pycryptodomex>=3.7.0',
'requests>=2.9.1',
'urllib3<2',
'vdf>=3.3',
'cachetools>=3.0.0',
"win-inet-pton; python_version == '2.7' and sys_platform == 'win32'",
"enum34==1.1.2; python_version < '3.4'",
]

install_extras = {
'client': [
'gevent>=1.3.0',
'protobuf~=3.0; python_version >= "3"',
'protobuf<3.18.0; python_version < "3"',
'protobuf~=3.0',
'gevent-eventemitter~=2.1',
],
}
Expand All @@ -38,24 +34,24 @@
version=__version__,
description='Module for interacting with various Steam features',
long_description=long_description,
url='https://github.com/ValvePython/steam',
author="Rossen Georgiev",
author_email='[email protected]',
url='https://github.com/solsticegamestudios/steam',
author="Rossen Georgiev / Solstice Game Studios",
author_email='[email protected]',
license='MIT',
python_requires=">=3.6",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Natural Language :: English',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: PyPy',
],
keywords='valve steam steamid api webapi steamcommunity',
Expand Down
8 changes: 0 additions & 8 deletions steam/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from io import open
from getpass import getpass
import logging
import six

from eventemitter import EventEmitter
from steam.enums import EResult, EOSType, EPersonaState
Expand All @@ -35,13 +34,6 @@
from steam.utils.proto import proto_fill_from_dict


# TODO: remove py2 support.
if six.PY2:
_cli_input = raw_input
else:
_cli_input = input


class SteamClient(CMClient, BuiltinBase):
EVENT_LOGGED_ON = 'logged_on'
"""After successful login"""
Expand Down
3 changes: 1 addition & 2 deletions steam/client/builtins/friends.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from six import itervalues
from eventemitter import EventEmitter
from steam.steamid import SteamID, intBase
from steam.enums import EResult, EFriendRelationship
Expand Down Expand Up @@ -129,7 +128,7 @@ def __len__(self):
return len(self._fr)

def __iter__(self):
return itervalues(self._fr)
return self._fr.values()

def __list__(self):
return list(iter(self))
Expand Down
18 changes: 6 additions & 12 deletions steam/client/cdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
from zipfile import ZipFile
from io import BytesIO
from collections import OrderedDict, deque
from six import itervalues, iteritems
from binascii import crc32, unhexlify
from datetime import datetime
import logging
Expand All @@ -114,11 +113,8 @@
from steam.core.crypto import symmetric_decrypt, symmetric_decrypt_ecb
from steam.core.manifest import DepotManifest, DepotFile
from steam.protobufs.content_manifest_pb2 import ContentManifestPayload
import lzma

try:
import lzma
except ImportError:
from backports import lzma

def decrypt_manifest_gid_2(encrypted_gid, password):
"""Decrypt manifest gid v2 bytes
Expand Down Expand Up @@ -164,7 +160,7 @@ def get_content_servers_from_cs(cell_id, host='cs.steamcontent.com', port=80, nu

servers = []

for entry in itervalues(kv['serverlist']):
for entry in kv['serverlist'].values():
server = ContentServer()
server.type = entry['type']
server.https = True if entry['https_support'] == 'mandatory' else False
Expand Down Expand Up @@ -497,9 +493,9 @@ def load_licenses(self):
return

packages = list(map(lambda l: {'packageid': l.package_id, 'access_token': l.access_token},
itervalues(self.steam.licenses)))
self.steam.licenses.values()))

for package_id, info in iteritems(self.steam.get_product_info(packages=packages)['packages']):
for package_id, info in self.steam.get_product_info(packages=packages)['packages'].items():
self.licensed_app_ids.update(info['appids'].values())
self.licensed_depot_ids.update(info['depotids'].values())

Expand Down Expand Up @@ -800,7 +796,7 @@ def async_fetch_manifest(
tasks = []
shared_depots = {}

for depot_id, depot_info in iteritems(depots):
for depot_id, depot_info in depots.items():
if not depot_id.isdigit():
continue

Expand Down Expand Up @@ -866,7 +862,7 @@ def async_fetch_manifest(
manifests.append(result)

# load shared depot manifests
for app_id, depot_ids in iteritems(shared_depots):
for app_id, depot_ids in shared_depots.items():
def nested_ffunc(depot_id, depot_info, depot_ids=depot_ids, ffunc=filter_func):
return (int(depot_id) in depot_ids
and (ffunc is None or ffunc(depot_id, depot_info)))
Expand Down Expand Up @@ -939,5 +935,3 @@ def get_manifest_for_workshop_item(self, item_id):

manifest.name = wf.title
return manifest


6 changes: 1 addition & 5 deletions steam/core/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class UniverseKey(object):

BS = 16
pad = lambda s: s + (BS - len(s) % BS) * pack('B', BS - len(s) % BS)

if sys.version_info < (3,):
unpad = lambda s: s[0:-ord(s[-1])]
else:
unpad = lambda s: s[0:-s[-1]]
unpad = lambda s: s[0:-s[-1]]


def generate_session_key(hmac_secret=b''):
Expand Down
7 changes: 1 addition & 6 deletions steam/core/msg/structs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Classes to (de)serialize various struct messages"""
import struct
import six
import vdf
from six.moves import range
from steam.enums import EResult, EUniverse
from steam.enums.emsg import EMsg
from steam.utils.binary import StructReader
Expand All @@ -26,8 +24,7 @@ def __new__(metacls, name, bases, classdict):

return cls

@six.add_metaclass(StructMessageMeta)
class StructMessage:
class StructMessage(object, metaclass=StructMessageMeta):
def __init__(self, data=None):
if data: self.load(data)

Expand All @@ -37,7 +34,6 @@ def serialize(self):
def load(self, data):
raise NotImplementedError


class ChannelEncryptRequest(StructMessage):
protocolVersion = 1
universe = EUniverse.Invalid
Expand Down Expand Up @@ -426,4 +422,3 @@ def __str__(self):

class ClientPasswordChangeResponse(_ResultStruct):
pass

8 changes: 1 addition & 7 deletions steam/globalid.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import sys
from datetime import datetime, timedelta

if sys.version_info < (3,):
intBase = long
else:
intBase = int


class GlobalID(intBase):
class GlobalID(int):
"""
Represents a globally unique identifier within the Steam network.
Guaranteed to be unique across all racks and servers for a given Steam universe.
Expand Down
7 changes: 1 addition & 6 deletions steam/steamid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
from steam.core.crypto import md5_hash
from steam.utils.web import make_requests_session

if sys.version_info < (3,):
intBase = long
else:
intBase = int

class ETypeChar(SteamIntEnum):
I = EType.Invalid
U = EType.Individual
Expand Down Expand Up @@ -40,7 +35,7 @@ def __str__(self):
_csgofrcode_chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'


class SteamID(intBase):
class SteamID(int):
"""
Object for converting steamID to its' various representations
Expand Down
8 changes: 1 addition & 7 deletions steam/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"""Utility package with various useful functions
"""
import six
from six.moves import xrange as _range
import sys

if six.PY2 and sys.platform == 'win32':
import win_inet_pton

import weakref
import struct
import socket
Expand Down Expand Up @@ -63,7 +57,7 @@ def chunks(arr, size):
:return: generator object
:rtype: :class:`generator`
"""
for i in _range(0, len(arr), size):
for i in range(0, len(arr), size):
yield arr[i:i+size]


Expand Down
9 changes: 1 addition & 8 deletions steam/utils/proto.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@

import six
from types import GeneratorType as _GeneratorType
from google.protobuf.message import Message as _ProtoMessageType


if six.PY2:
_list_types = list, xrange, _GeneratorType
else:
_list_types = list, range, _GeneratorType, map, filter

_list_types = list, range, _GeneratorType, map, filter
protobuf_mask = 0x80000000


Expand Down
11 changes: 2 additions & 9 deletions steam/utils/throttle.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import sys
import time

if sys.version_info >= (3,3):
_monotonic = time.monotonic
else:
_monotonic = time.time # not really monotonic vOv


class ConstantRateLimit(object):
def __init__(self, times, seconds, exit_wait=False, sleep_func=time.sleep):
Expand Down Expand Up @@ -47,14 +42,12 @@ def __exit__(self, etype, evalue, traceback):
self.wait()

def _update_ref(self):
self._ref = _monotonic() + self.rate
self._ref = time.monotonic() + self.rate

def wait(self):
"""Blocks until the rate is met"""
now = _monotonic()
now = time.monotonic()
if now < self._ref:
delay = max(0, self._ref - now)
self.sleep_func(delay)
self._update_ref()


15 changes: 2 additions & 13 deletions steam/webauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
from time import time, sleep
from base64 import b64encode
from getpass import getpass
import six
import requests

from steam.enums.proto import EAuthSessionGuardType, EAuthTokenPlatformType, ESessionPersistence
Expand All @@ -67,16 +66,6 @@
from steam.core.crypto import rsa_publickey, pkcs1v15_encrypt


# TODO: Remove python2 support.
# TODO: Encrease min python version to 3.5

if six.PY2:
intBase = long
_cli_input = raw_input
else:
intBase = int
_cli_input = input

API_HEADERS = {
'origin': 'https://steamcommunity.com',
'referer': 'https://steamcommunity.com/',
Expand Down Expand Up @@ -189,8 +178,8 @@ def _encrypt_password(self):
"""
r = self._get_rsa_key()

mod = intBase(r['response']['publickey_mod'], 16)
exp = intBase(r['response']['publickey_exp'], 16)
mod = int(r['response']['publickey_mod'], 16)
exp = int(r['response']['publickey_exp'], 16)

pub_key = rsa_publickey(mod, exp)
encrypted = pkcs1v15_encrypt(pub_key, self.password.encode('ascii'))
Expand Down
6 changes: 1 addition & 5 deletions tests/generete_webauth_vcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

from steam import webauth as wa

try:
_input = raw_input
except:
_input = input

# personal info scrubbers
# -----------------------
Expand Down Expand Up @@ -80,7 +76,7 @@ def response_scrubber(r):

def user_pass_only():
print("Please enter a user that can login with just password.")
u = _input("Username: ")
u = input("Username: ")
p = getpass("Password (no echo): ")

user_pass_only_success(u, p)
Expand Down

0 comments on commit 6f97b3a

Please sign in to comment.