Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package the application and some additional info messages #131

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "updatershell/platform"]
path = updatershell/platform
url = https://github.com/ma1co/OpenMemories-Platform
[submodule "pmca/data/updatershell/platform"]
path = pmca/data/updatershell/platform
url = https://github.com/ma1co/OpenMemories-Platform.git
File renamed without changes.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graft pmca/data/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The list of available apps can be found at [sony-pmca.appspot.com](https://sony-

**pmca-gui is the recommended way to install apps.** Binaries for Windows and OS X are available in the [release section](https://github.com/ma1co/Sony-PMCA-RE/releases/latest). Download and open the program, connect your camera via USB, go to the *Install* tab, select an app from the list and click *Install*.

To install on Linux simply run ``` pip install git+https://github.com/ma1co/Sony-PMCA-RE.git@master ``` and **pmca-gui** and **pmca-console** will be avaiable in your shell.

Further information can be found in the sections below.

## Tweaking camera settings ##
Expand Down Expand Up @@ -72,6 +74,9 @@ On Windows, the choice defaults to the default Windows USB drivers. If you want
#### OS X drivers ####
On OS X, to communicate with cameras in mass storage mode, the [PMCADownloader](https://sony-pmca.appspot.com/plugin/install) browser plugin and/or the [DriverLoader](https://support.d-imaging.sony.co.jp/mac/driver/1013/en/) application have to be installed.

#### Linux drivers ####
Linux does not have any native Sony drivers so libusb-MSC or libusb-MTP will be used. No need to do anything special to communicate with the camera via app install or update mode.

## Is it safe? ##
This is an experiment in a very early stage. All information has been found through reverse engineering. Even though everything worked fine for our developers, it could cause harm to your hardware. If you break your camera, you get to keep both pieces. **We won't take any responsibility.**

Expand Down
4 changes: 2 additions & 2 deletions build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ suffix = {'linux2': '-linux', 'win32': '-win', 'darwin': '-osx'}
output += '-' + version + suffix.get(sys.platform, '')

# Analyze files
a = Analysis([input], excludes=excludes, datas=[('certs/*', 'certs')])
a = Analysis([input], excludes=excludes, datas=[('pmca/data/certs/*', 'pmca/data/certs')])
a.datas = [d for d in a.datas if not (d[0].startswith('certifi') and not d[0].endswith('cacert.pem'))]
a.datas += Tree('updatershell/fdat', 'updatershell/fdat')
a.datas += Tree('pmca/data/updatershell/fdat', 'pmca/data/updatershell/fdat')

# Generate executable
pyz = PYZ(a.pure, a.zipped_data)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pmca-console.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run `pyinstaller pmca-console.spec` to generate an executable

input = 'pmca-console.py'
input = 'pmca-console'
output = 'pmca-console'
console = True

Expand Down
2 changes: 1 addition & 1 deletion pmca-gui.py → pmca-gui
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import traceback
import webbrowser

import config
from pmca.config import config
from pmca.commands.usb import *
from pmca.ui import *
from pmca.usb.usbshell import *
Expand Down
2 changes: 1 addition & 1 deletion pmca-gui.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run `pyinstaller pmca-gui.spec` to generate an executable

input = 'pmca-gui.py'
input = 'pmca-gui'
output = 'pmca-gui'
console = False

Expand Down
8 changes: 4 additions & 4 deletions pmca/commands/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Python 2
input = raw_input

import config
from ..config import config
from ..apk import *
from .. import appstore
from .. import firmware
Expand Down Expand Up @@ -57,7 +57,7 @@ def listApps(enableCache=False):

def installApp(dev, apkFile=None, appPackage=None, outFile=None, local=False):
"""Installs an app on the specified device."""
certFile = scriptRoot + '/certs/localtest.me.pem'
certFile = scriptRoot + '/pmca/data/certs/localtest.me.pem'
with ServerContext(LocalMarketServer(certFile, config.officialServer)) as server:
apkData = None
if apkFile:
Expand Down Expand Up @@ -307,7 +307,7 @@ def appSelectionCommand():


def getFdats():
fdatDir = scriptRoot + '/updatershell/fdat/'
fdatDir = scriptRoot + '/pmca/data/updatershell/fdat/'
for dir in os.listdir(fdatDir):
if os.path.isdir(fdatDir + dir):
payloadFile = fdatDir + dir + '.dat'
Expand Down Expand Up @@ -385,7 +385,7 @@ def firmwareUpdateCommandInternal(driver, device, file, offset, size, complete=N
device = None
print('')
print('Waiting for camera to switch...')
print('Please follow the instructions on the camera screen.')
print('Please follow the instructions on the camera screen or press record button.')
for i in range(60):
time.sleep(.5)
try:
Expand Down
1 change: 1 addition & 0 deletions pmca/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import config
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions pmca/usb/sony.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def __init__(self, dev):
self.dev = dev

def _sendCommand(self, cmd, data=b'', writeBufferSize=0x2000, readBufferSize=0x2000):
if not hasattr(self.dev, 'sendSonyExtCommand'):
raise Exception('_sendCommand: Devices does not have sendSonyExtCommand, please power cycle and reconnect device.')
data = self.dev.sendSonyExtCommand(cmd[0], (self.ExtCmdHeader.pack(
dataSize = len(data),
cmd = cmd[1],
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ asn1crypto
certifi
comtypes; sys_platform == 'win32'
pycryptodomex
pyinstaller
pyusb
pywin32; sys_platform == 'win32'
pyyaml
63 changes: 63 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from __future__ import print_function
import os
from glob import glob
from subprocess import check_output

from setuptools import setup, find_packages

PKG_DIR = os.path.dirname(os.path.realpath(__file__))

def git_cmd(p, args):
g = ['git', '-C', p]
return check_output(g + args).decode('UTF-8').strip().lstrip('v')

def git_version(p):
ver_all = git_cmd(p, ['describe', '--tags', '--dirty=.dirty'])
ver_tag = git_cmd(p, ['describe', '--tags', '--abbrev=0'])
return ver_tag + ver_all[len(ver_tag):].replace('-', '.dev', 1).replace('-', '+', 1)

with open('README.md') as f:
long_description = f.read()

with open('requirements.txt') as f:
requirements = f.read().splitlines()

if os.path.exists('version.txt'):
with open('version.txt') as f:
version = f.read().strip()
else:
version = git_version(PKG_DIR)

setup(
name='Sony-PMCA-RE',
version=version,
install_requires=requirements,
author='ma1co',
author_email='[email protected]',
packages=find_packages(exclude=('build', 'dist',)),
include_package_data=True,
url='https://github.com/ma1co/Sony-PMCA-RE',
license='MIT',
description='Reverse engineering Sony PlayMemories Camera Apps',
long_description=long_description,
scripts=['pmca-console',
'pmca-gui'],
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
)